|
I have an WPF XAML application where I need to capture a portion of the page and send it to the printer. I have gone through the Microsoft print dialog control reference and see how I can save an xps formatted document then load it into the print dialog and send it to the printer. Now I have read an article indicating that all I have to do is create a FixedDocument and bind my values to it's datacontext and then save the completed FixedDocument, reload it and send it to the pring dialog as an xps file which is what I want. The fixed page XAML is shown below:
<FixedDocument
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xml:lang="en-au">
<FixedDocument.Resources>
<BooleanToVisibilityConverter x:Key="visConverter"/>
</FixedDocument.Resources>
<PageContent>
<FixedPage Width="793.76" Height="1122.56">
<!-- Page 1 Begins Here -->
<StackPanel Margin="50">
<Border BorderThickness="5" BorderBrush="Gray" CornerRadius="10"
Padding="20" Width="690">
<StackPanel Orientation="Horizontal" Margin="0 0 0 0">
<Image Source="truck.jpg" HorizontalAlignment="Left"/>
<TextBlock Margin="30 0 0 0" FontSize="50"
Text="{Binding Path=Heading}" VerticalAlignment="Center"/>
</StackPanel>
</Border>
<TextBlock Margin="0 30 0 0"
Text="{Binding Path=CurrentDate, StringFormat='{}{0:d MMMM yyyy}'}"/>
<TextBlock Margin="0 30 0 0"
Text="{Binding Path=Name, StringFormat='Dear {0},'}" />
<ItemsControl Margin="30 20 0 0" ItemsSource="{Binding Path=DotPoints}"
HorizontalAlignment="Left">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,8,0,0" Orientation="Horizontal" >
<TextBlock Text="• " />
<TextBlock Text="{Binding}" TextWrapping="Wrap" Width="400"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<TextBlock Margin="0 30 0 0"
Text="Congratulations, you are entitled to a 50% discount!"
Visibility="{Binding Path=GiveDiscount,
Converter={StaticResource visConverter}}"/>
</StackPanel>
</FixedPage>
</PageContent>
<PageContent>
<FixedPage Width="793.76" Height="1122.56">
<!-- Page 2 Begins Here -->
<TextBlock Margin="50" Text="Nothing to see here."/>
</FixedPage>
</PageContent>
</FixedDocument>
Now when I try to add XAML to the page I get an error: Property 'pages' does no support a value of type 'PageContent.
Now I tried a different approach. Now to resolve this I have reviewed many articles until I came to one that looks like it will do the trick but it gives me an error as well. What error I get is it can not convert a FixedPage to an UIElement. The code is below:
<Window
x:Class="ODIN.DataSheetFixedDocument"
WindowStartupLocation="CenterScreen"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:v="clr-namespace:ODIN.View"
xmlns:local="clr-namespace:ODIN"
local:WindowCustomizer.CanMaximize="False"
local:WindowCustomizer.CanMinimize="False"
Title="Administrated Master View"
Width="1024"
Height="768"
>
<Grid Name="MainGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="97*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="115*" />
</Grid.RowDefinitions>
<FixedPage Width="1024" Height="768" x:Name="theFixedPage">
<StackPanel Background="Green" Width="200" Height="30" HorizontalAlignment="Left" Margin="0,100,0,0" Grid.Column="0" Grid.Row="0">
<TextBlock Width="465" HorizontalAlignment="Left" Height="92" Foreground="Black" Margin="0,0,-265,0">Hello</TextBlock>
</StackPanel>
</FixedPage>
<DocumentViewer>
<FixedDocument x:Name="uiFixedDocument">
</FixedDocument>
</DocumentViewer>
</Grid>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace ODIN
{
public partial class DataSheetFixedDocument : Window
{
public DataSheetFixedDocument()
{
InitializeComponent();
Grid grid = new Grid();
grid = (Grid)this.theFixedPage.Parent;
grid.Children.Remove(this.theFixedPage);
PageContent pageContent = new PageContent();
pageContent.Child = theFixedPage;
FixedDocument.Pages.Add(pageContent);
uiFixedDocument.Pages.Add(pageContent);
grid.Children.Add((UIElement) uiFixedDocument);
}
}
}
Now if I don't try to add it to the Grid it runs but my FixedPage does not display.
If anyone can see what I'm doing wrong help would be great.
modified 5-Oct-16 14:18pm.
|
|
|
|
|
I came up with an easy solution. Because I am only printing the XAML page that is being displayed, except for a few areas that I can collapse, here is what I did. On the XAML page it has a print stackpanel with the print button and header text I need to remove. After collapsing these elements I just use the PrintDialog PrintVisual(MainPageGrid, "Title"); method.
|
|
|
|
|
Hi,
That's really frustrating, some days ago I felt on a tutorial page on how to animate grids (or contentcontrol...I don't remember).
...and now that I need this page I can't find it again
There was an illustration like this (light blue squares)
http://i.imgur.com/PzcdoVs.png[^]
The principle being to animate scale in/out for centered object and opacity in/out for first and last object
Would you by chance see the page I'm referring to? (or at least lead me to a similar article!)
Thanks a lot!!
|
|
|
|
|
Try searching your browser history.
|
|
|
|
|
I don't have access anymore to the computer (school) I used at the time!
|
|
|
|
|
Then you will need to search the articles section for yourself.
|
|
|
|
|
Hi All,
I have created the Virtual Directory on the Server and copied all .exe, xbap and manifest files, when trying to access the xbap application, I'm getting the following error. Please help me what steps am I missing in deploying the application.
Here is the Error log message
PLATFORM VERSION INFO
Windows : 6.1.7601.65536 (Win32NT)
Common Language Runtime : 4.0.30319.42000
System.Deployment.dll : 4.6.118.0 built by: NETFXREL3STAGE
clr.dll : 4.6.1076.0 built by: NETFXREL3STAGE
dfdll.dll : 4.6.118.0 built by: NETFXREL3STAGE
dfshim.dll : 4.0.41209.0 (Main.041209-0000)
SOURCES
Deployment url : <a href="http://localhost/WPFBrowserApplication/WpfBrowserApplication12015.xbap">http:
Application url : <a href="http://localhost/WPFBrowserApplication/WpfBrowserApplication12015.exe.manifest">http:
IDENTITIES
Deployment Identity : WpfBrowserApplication12015.xbap, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c836e075e9e59aa1, processorArchitecture=msil
Application Identity : WpfBrowserApplication12015.exe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c836e075e9e59aa1, processorArchitecture=msil, type=win32
APPLICATION SUMMARY
* Online only application.
* Browser-hosted application.
ERROR SUMMARY
Below is a summary of the errors, details of these errors are listed later in the log.
* An exception occurred while downloading the application. Following failure messages were detected:
+ Downloading <a href="http://localhost/WPFBrowserApplication/WpfBrowserApplication12015.exe.deploy">http:
+ The remote server returned an error: (404) Not Found.
COMPONENT STORE TRANSACTION FAILURE SUMMARY
No transaction error was detected.
WARNINGS
There were no warnings during this operation.
OPERATION PROGRESS STATUS
No phase information is available.
ERROR DETAILS
Following errors were detected during this operation.
* [9/18/2016 8:02:15 PM] System.Deployment.Application.DeploymentDownloadException (Unknown subtype)
- Downloading <a href="http://localhost/WPFBrowserApplication/WpfBrowserApplication12015.exe.deploy">http:
- Source: System.Deployment
- Stack trace:
at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
at System.Deployment.Application.SystemNetDownloader.DownloadAllFiles()
at System.Deployment.Application.FileDownloader.Download(SubscriptionState subState)
at System.Deployment.Application.DownloadManager.DownloadDependencies(SubscriptionState subState, AssemblyManifest deployManifest, AssemblyManifest appManifest, Uri sourceUriBase, String targetDirectory, String group, IDownloadNotification notification, DownloadOptions options)
at System.Deployment.Application.DeploymentManager.SynchronizeCore(Boolean blocking)
at System.Deployment.Application.DeploymentManager.SynchronizeAsyncWorker()
- Inner Exception -
System.Net.WebException
- The remote server returned an error: (404) Not Found.
- Source: System
- Stack trace:
at System.Net.HttpWebRequest.GetResponse()
at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
COMPONENT STORE TRANSACTION DETAILS
No transaction information is available.
I am searching and asking with friends and colleagues, any type of help is appreciated maybe a code snippet, a link or even a suggestions help. Thanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
indian143 wrote: The remote server returned an error: (404) Not Found.
Either your files do not exist on your server, or you haven't configured the MIME type for them.
MIME Types for ClickOnce deployment | RobinDotNet's Blog[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I tried but I don't know how to install mime types on a Virtual Directory or Web Application, I found some vbs code I saved and ran it to install Mime types, it gave me error.
So far I couldn't find how to install MIME types, can you please help me with that?
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
Did you read the blog post I linked to? It has links to Microsoft's instructions for setting up MIME types in IIS.
Instructions for setting up MIME types in IIS6:
Configure MIME Types (IIS 6.0)[^]
Instructions for setting up MIME types in IIS7 (or later):
Configuring MIME Types in IIS 7[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
I installed all those Mime types on my Server, still I am getting the same error, can you please give me some suggestion about it?
I have copied .exe file, .manifest file and .xbap file from bin directory of the application into Virtual Directory, am I missing anything here? Do I need to have .deploy file etc?
I followed all the steps that are provided here : GADS Open Source[^]
If I'm missing something please let me know, any help is greatly appreciated. Thanks my friend .
Still I am getting the following Error:
PLATFORM VERSION INFO
Windows : 6.1.7601.65536 (Win32NT)
Common Language Runtime : 4.0.30319.42000
System.Deployment.dll : 4.6.1055.0 built by: NETFXREL2
clr.dll : 4.6.1076.0 built by: NETFXREL3STAGE
dfdll.dll : 4.6.1055.0 built by: NETFXREL2
dfshim.dll : 4.0.41209.0 (Main.041209-0000)
SOURCES
Deployment url : http://localhost/WpfBrowserApplication12015/WpfBrowserApplication12015.xbap
Application url : http://localhost/WpfBrowserApplication12015/WpfBrowserApplication12015.exe.manifest
IDENTITIES
Deployment Identity : WpfBrowserApplication12015.xbap, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c836e075e9e59aa1, processorArchitecture=msil
Application Identity : WpfBrowserApplication12015.exe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c836e075e9e59aa1, processorArchitecture=msil, type=win32
APPLICATION SUMMARY
* Online only application.
* Browser-hosted application.
ERROR SUMMARY
Below is a summary of the errors, details of these errors are listed later in the log.
* An exception occurred while downloading the application. Following failure messages were detected:
+ Downloading http://localhost/WpfBrowserApplication12015/WpfBrowserApplication12015.exe.deploy did not succeed.
+ The remote server returned an error: (404) Not Found.
COMPONENT STORE TRANSACTION FAILURE SUMMARY
No transaction error was detected.
WARNINGS
There were no warnings during this operation.
OPERATION PROGRESS STATUS
No phase information is available.
ERROR DETAILS
Following errors were detected during this operation.
* [9/20/2016 2:25:44 PM] System.Deployment.Application.DeploymentDownloadException (Unknown subtype)
- Downloading http://localhost/WpfBrowserApplication12015/WpfBrowserApplication12015.exe.deploy did not succeed.
- Source: System.Deployment
- Stack trace:
at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
at System.Deployment.Application.SystemNetDownloader.DownloadAllFiles()
at System.Deployment.Application.FileDownloader.Download(SubscriptionState subState)
at System.Deployment.Application.DownloadManager.DownloadDependencies(SubscriptionState subState, AssemblyManifest deployManifest, AssemblyManifest appManifest, Uri sourceUriBase, String targetDirectory, String group, IDownloadNotification notification, DownloadOptions options)
at System.Deployment.Application.DeploymentManager.SynchronizeCore(Boolean blocking)
at System.Deployment.Application.DeploymentManager.SynchronizeAsyncWorker()
- Inner Exception -
System.Net.WebException
- The remote server returned an error: (404) Not Found.
- Source: System
- Stack trace:
at System.Net.HttpWebRequest.GetResponse()
at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
COMPONENT STORE TRANSACTION DETAILS
No transaction information is available
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
modified 20-Sep-16 17:32pm.
|
|
|
|
|
indian143 wrote: Downloading http://localhost/WpfBrowserApplication12015/WpfBrowserApplication12015.exe.deploy did not succeed.
- The remote server returned an error: (404) Not Found.
Either the .deploy file does not exist in that path on your server, or you didn't configure the MIME type for .deploy files.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I configured .deploy mime type on the IIS Rick not able figure it out my friend, still checking, Silverlight Application is working on the same IIS, only WPF browser app is not working.
Do I need to set up anything in the App Config file any properties etc.? Do I need to put some Certificate related information on the Config file? I am not sure - I have been searching my friend. That one little thing can keep my Work going - thanks for coming up to help me my friend.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
If you request http://localhost/WpfBrowserApplication12015/WpfBrowserApplication12015.exe.deploy in your web browser, do you get the file, or do you get an error?
If you get an error, try using failed request tracing[^] to diagnose the problem.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yes when I type this in the browser ()[^] I am getting file not found error (404).
I don't know what it means and how to resolve it my friend, sincerely and seriously
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
So try the failed request tracing, as I suggested.
Either the file doesn't exist, or something isn't configured properly in IIS. Failed request tracing will tell you what the problem is.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have enabled the IIS request failed tracing I got the following xml file, can you please help me in finding out what I am missing when I try to make request for the .deploy as mentioned in the above message you sent me. I tried to put the message here but the thing is here its not taking the HTML message of that long. But anyways I am not able to understand why is it failing.
Can you please help in that aspect a little bit?
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type='text/xsl' href='freb.xsl'?>
<!-- saved from url=(0014)about:internet -->
<failedRequest url="http://localhost:80/WpfBrowserApplication12015/WpfBrowserApplication12015.exe.deploy"
siteId="1"
appPoolId="WPF Browser App Pool"
processId="9100"
verb="GET"
remoteUserName=""
userName=""
tokenUserName="NT AUTHORITY\IUSR"
authenticationType="anonymous"
activityId="{00000000-0000-0000-0600-0080020000FF}"
failureReason="STATUS_CODE"
statusCode="404"
triggerStatusCode="404"
timeTaken="62"
xmlns:freb="http://schemas.microsoft.com/win/2006/06/iis/freb"
>
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="WWW Server" Guid="{3A2A4E84-4C21-4981-AE10-3FDA0D9B0F83}"/>
<EventID>0</EventID>
<version>1
<level>0
<opcode>1
<keywords>0x0
<TimeCreated SystemTime="2016-09-21T17:55:47.580Z"/>
<Correlation ActivityID="{00000000-0000-0000-0600-0080020000FF}"/>
<Execution ProcessID="9100" ThreadID="15072"/>
<Computer>BSCWL751990</Computer>
</System>
<EventData>
<Data Name="ContextId">{00000000-0000-0000-0600-0080020000FF}</Data>
<Data Name="SiteId">1</Data>
<Data Name="AppPoolId">WPF Browser App Pool</Data>
<Data Name="ConnId">1610612741</Data>
<Data Name="RawConnId">0</Data>
<Data Name="RequestURL">http:
<Data Name="RequestVerb">GET</Data>
</EventData>
<RenderingInfo Culture="en-US">
<Opcode>GENERAL_REQUEST_START</Opcode>
</RenderingInfo>
<ExtendedTracingInfo xmlns="http://schemas.microsoft.com/win/2004/08/events/trace">
<EventGuid>{D42CF7EF-DE92-473E-8B6C-621EA663113A}</EventGuid>
</ExtendedTracingInfo>
</Event>
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="WWW Server" Guid="{3A2A4E84-4C21-4981-AE10-3FDA0D9B0F83}"/>
<EventID>0</EventID>
<Version>1</Version>
<Level>5</Level>
<Opcode>4</Opcode>
<Keywords>0x100</Keywords>
<TimeCreated SystemTime="2016-09-21T17:55:47.580Z"/>
<Correlation ActivityID="{00000000-0000-0000-0600-0080020000FF}"/>
<Execution ProcessID="9100" ThreadID="15072"/>
<Computer>BSCWL751990</Computer>
</System>
<EventData>
<Data Name="ContextId">{00000000-0000-0000-0600-0080020000FF}</Data>
<Data Name="ModuleName">FailedRequestsTracingModule</Data>
</EventData>
<RenderingInfo Culture="en-US">
<Opcode>PRE_BEGIN_REQUEST_START</Opcode>
<Keywords>
<Keyword>RequestNotifications</Keyword>
</Keywords>
</RenderingInfo>
<ExtendedTracingInfo xmlns="http://schemas.microsoft.com/win/2004/08/events/trace">
<EventGuid>{002E91E3-E7AE-44AB-8E07-99230FFA6ADE}</EventGuid>
</ExtendedTracingInfo>
</Event>
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="WWW Server" Guid="{3A2A4E84-4C21-4981-AE10-3FDA0D9B0F83}"/>
<EventID>0</EventID>
<Version>1</Version>
<Level>5</Level>
<Opcode>5</Opcode>
<Keywords>0x100</Keywords>
<TimeCreated SystemTime="2016-09-21T17:55:47.580Z"/>
<Correlation ActivityID="{00000000-0000-0000-0600-0080020000FF}"/>
<Execution ProcessID="9100" ThreadID="15072"/>
<Computer>BSCWL751990</Computer>
</System>
<EventData>
<Data Name="ContextId">{00000000-0000-0000-0600-0080020000FF}</Data>
<Data Name="ModuleName">FailedRequestsTracingModule</Data>
<Data Name="NotificationStatus">0</Data>
</EventData>
<RenderingInfo Culture="en-US">
<Opcode>PRE_BEGIN_REQUEST_END</Opcode>
<Keywords>
<Keyword>RequestNotifications</Keyword>
</Keywords>
<freb:Description Data="NotificationStatus">NOTIFICATION_CONTINUE</freb:Description>
</RenderingInfo>
<ExtendedTracingInfo xmlns="http://schemas.microsoft.com/win/2004/08/events/trace">
<EventGuid>{002E91E3-E7AE-44AB-8E07-99230FFA6ADE}</EventGuid>
</ExtendedTracingInfo>
</Event>
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="WWW Server" Guid="{3A2A4E84-4C21-4981-AE10-3FDA0D9B0F83}"/>
<EventID>0</EventID>
<Version>1</Version>
<Level>5</Level>
<Opcode>4</Opcode>
<Keywords>0x100</Keywords>
<TimeCreated SystemTime="2016-09-21T17:55:47.580Z"/>
<Correlation ActivityID="{00000000-0000-0000-0600-0080020000FF}"/>
<Execution ProcessID="9100" ThreadID="15072"/>
<Computer>BSCWL751990</Computer>
</System>
<EventData>
<Data Name="ContextId">{00000000-0000-0000-0600-0080020000FF}</Data>
<Data Name="ModuleName">RequestMonitorModule</Data>
</EventData>
<RenderingInfo Culture="en-US">
<Opcode>PRE_BEGIN_REQUEST_START</Opcode>
<Keywords>
<Keyword>RequestNotifications</Keyword>
</Keywords>
</RenderingInfo>
<ExtendedTracingInfo xmlns="http://schemas.microsoft.com/win/2004/08/events/trace">
<EventGuid>{002E91E3-E7AE-44AB-8E07-99230FFA6ADE}</EventGuid>
</ExtendedTracingInfo>
</Event>
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="WWW Server" Guid="{3A2A4E84-4C21-4981-AE10-3FDA0D9B0F83}"/>
<EventID>0</EventID>
<Version>1</Version>
<Level>5</Level>
<Opcode>5</Opcode>
<Keywords>0x100</Keywords>
<TimeCreated SystemTime="2016-09-21T17:55:47.580Z"/>
<Correlation ActivityID="{00000000-0000-0000-0600-0080020000FF}"/>
<Execution ProcessID="9100" ThreadID="15072"/>
<Computer>BSCWL751990</Computer>
</System>
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
Not without seeing the full file.
If you open the XML file in Internet Explorer, you should see a detailed log of the failed request, and the breakdown of what caused the error.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
xml file is too big, can you please give me some hints where to look or some searching criteria mostly its saying 400 error and not saying which file is missing my friend. I know its kind of bugging for you.
If you can help me its really great - thank you.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
If you open the XML file in Internet Explorer, you will get a formatted list of errors and warnings.
If you can't work out what they mean, then post the file to a new GitHub Gist[^] and provide the link.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have a situation where I am trying to change the visibility of StackPanels in a child UserControl from a button in the parent window. I created a custom class below that holds a static reference to the UserControl value and in the UserControl View constructor the user control value is assigned to the static EditWindow class uc static value. Now what I am trying to do is hide and show StackPanels in the child UserControl view the button in the parent window is clicked. When the button is clicked the StackPanels are not changing from Collapsed to Visible. All of the code is below:
EditWindow.cs
public static class EditWindow
{
public static string buttonString;
public static Button button;
public static View.ApplicationInfoView uc;
}
<v:ApplicationInfoView />
ApplicationInfoView StackPanels
<StackPanel Name="Sp1">
<StackPanel Name="Sp2">
<StackPanel Name="Sp2">
EditWindow.uc = this;
private void btnEdit_Click(object sender, RoutedEventArgs)
{
EditWindow.uc.editAppInfo();
}
editAppInfo()
{
EditWindow.uc.sp1.Visibility = Visibility.Collapsed;
EditWindow.uc.sp2.Visibility = Visibility.Visible;
EditWindow.uc.sp3.Visibility = Visibility.Visibile;
}
|
|
|
|
|
If the StackPanels are "empty", toggling visibility will make no difference unless you use an explicit minimum height, width and / or color in order to "see" them.
Also, the layout (right or wrong) impacts what one sees (in-back versus in-front; etc); regardless of what the "code-behind" is doing.
|
|
|
|
|
I have now tried changing the way I am performing my task. Now in my child user control constructor I am loading the UserControl as follows:
// Remember EditWindow is a static class and uc is a static // public value of View.ApplicationInfoView which is the // UserControl that is a View with a base class of // UserControl.
EditWindow.uc = this;
And now calling the method the following on the parent window button click event:
// Remember the StackPanel spGrid is Collapsed onload
private void btn_click(object sender, RoutingEventArgs e)
{
EditWindow.uc.spGrid.Visibility = Visibility.Visible;
}
Now Here is my StackPanel on the child UserControl:
<StackPanel Name="spGrid" Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="2">
<Grid Name="Grid2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="425" />
<ColumnDefinition Width="425" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="25" />
<RowDefinition Height="75" />
<RowDefinition Height="75" />
<RowDefinition Height="75" />
<RowDefinition Height="75" />
<RowDefinition Height="75" />
<RowDefinition Height="75" />
<RowDefinition Height="75" />
</Grid.RowDefinitions>
<Label Height="36" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" FontSize="16" Background="#FF004A78" Content="Identifying Documents" FontWeight="Bold" Foreground="White" Margin="0,0,0,0"/>
<StackPanel Grid.Row="1" Grid.Column="0" >
<Border BorderBrush="White" BorderThickness="3">
<Border BorderBrush="Gray" BorderThickness="1">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<StackPanel Width="420" x:Name="_Passport" Margin="0,0,0,0" Height="65">
<StackPanel Orientation="Horizontal">
<TextBlock Height="45" Width="Auto" FontWeight="Bold" Foreground="#FF004A78" FontSize="18" x:Name="Passport_TextBlock" Text="Passport" TextAlignment="Left"/>
<Image Source="/Images/Attachments_button.jpg" Margin="180, 0, 0 ,0" MouseLeftButtonUp="Click_MouseLeftButtonUp" Name="PPTop" Width="Auto" Height="45" />
<Image Source="/Images/Attachments_button.jpg" Margin="50, 0, 0 ,0" Name="PPBottom" Width="Auto" Height="45" />
</StackPanel>
<TextBlock Height="20" Width="Auto" Foreground="#FF004A78" FontSize="12" TextWrapping="WrapWithOverflow" x:Name="Passport2_TextBlock" Text="(Color copy, top and bottom) Perferred Passport Top Passport Bottom" TextAlignment="Left"/>
</StackPanel>
</StackPanel>
</StackPanel>
</Border>
</Border>
</StackPanel>
</StackPanel>
</Grid>
</StackPanel>
Now, again the StackPanel I am trying to hide/show is Name="spGrid". It houses my Grid "Grid2". Now this StackPanel is housed in it's own Grid. Shown is the nested Grid. Also, I am only showing you only one of the rows in the nested Grid of StackPanel spGrid. The other rows have the same type of controls. Again I don't know why when my EditWindow static class's UserControl uc set's it's StackPanel spGrid to visible it stil stays hidden.
|
|
|
|
|
This is one of those situations where the XAML should be "re-considered". (The "depth" of this simple visual tree is sure ... "deep"...)
Even your top "stack panel" is imbedded in a Grid; so you've still not got the whole picture.
State what you're trying to do from a "user" / functional point-of-view, and you'll probably get some good design answers to get you off with a less "complicated" (XAML) design / approach.
|
|
|
|
|
The appropriate way to do this is to create a Tunnelling Routed Event that the Child User control listens to. And make that event fire when you click the button on the parent control. This article on MSDN explains how to declare a Routed Event
|
|
|
|
|