Click here to Skip to main content
14,271,310 members

Silverlight / WPF

 
GeneralRe: How to solve the echo in a MVVM project with external data updates Pin
ronald627-Nov-16 3:38
memberronald627-Nov-16 3:38 
GeneralRe: How to solve the echo in a MVVM project with external data updates Pin
Gerry Schmitz7-Nov-16 6:35
mveGerry Schmitz7-Nov-16 6:35 
GeneralRe: How to solve the echo in a MVVM project with external data updates Pin
Pete O'Hanlon7-Nov-16 10:44
protectorPete O'Hanlon7-Nov-16 10:44 
GeneralRe: How to solve the echo in a MVVM project with external data updates Pin
Gerry Schmitz7-Nov-16 11:36
mveGerry Schmitz7-Nov-16 11:36 
GeneralRe: How to solve the echo in a MVVM project with external data updates Pin
ronald629-Nov-16 0:01
memberronald629-Nov-16 0:01 
GeneralRe: How to solve the echo in a MVVM project with external data updates Pin
Gerry Schmitz10-Nov-16 12:11
mveGerry Schmitz10-Nov-16 12:11 
GeneralRe: How to solve the echo in a MVVM project with external data updates Pin
ronald6221-Nov-16 1:14
memberronald6221-Nov-16 1:14 
QuestionPrinting an xps fixed document Pin
holdorf5-Oct-16 8:04
memberholdorf5-Oct-16 8:04 
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
{
    /// <summary>
    /// Interaction logic for DataSheetFixedDocument.xaml
    /// </summary>
    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);
            // Below is where I get the not able to convert
            // FixedPage to an UIElement.
            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.

AnswerRe: Printing an xps fixed document Pin
holdorf5-Oct-16 9:56
memberholdorf5-Oct-16 9:56 
QuestionCoverflow like animating grids or contentcontrol Pin
Jayme655-Oct-16 0:44
memberJayme655-Oct-16 0:44 
SuggestionRe: Coverflow like animating grids or contentcontrol Pin
Richard MacCutchan5-Oct-16 2:24
protectorRichard MacCutchan5-Oct-16 2:24 
GeneralRe: Coverflow like animating grids or contentcontrol Pin
Jayme655-Oct-16 3:05
memberJayme655-Oct-16 3:05 
GeneralRe: Coverflow like animating grids or contentcontrol Pin
Richard MacCutchan5-Oct-16 3:05
protectorRichard MacCutchan5-Oct-16 3:05 
QuestionApplication download error in XBAP application after deploying the application Pin
indian14319-Sep-16 7:41
memberindian14319-Sep-16 7:41 
AnswerRe: Application download error in XBAP application after deploying the application Pin
Richard Deeming19-Sep-16 8:20
mveRichard Deeming19-Sep-16 8:20 
GeneralRe: Application download error in XBAP application after deploying the application Pin
indian14319-Sep-16 10:37
memberindian14319-Sep-16 10:37 
GeneralRe: Application download error in XBAP application after deploying the application Pin
Richard Deeming19-Sep-16 10:43
mveRichard Deeming19-Sep-16 10:43 
GeneralRe: Application download error in XBAP application after deploying the application Pin
indian14320-Sep-16 10:02
memberindian14320-Sep-16 10:02 
GeneralRe: Application download error in XBAP application after deploying the application Pin
Richard Deeming21-Sep-16 2:37
mveRichard Deeming21-Sep-16 2:37 
GeneralRe: Application download error in XBAP application after deploying the application Pin
indian14321-Sep-16 6:29
memberindian14321-Sep-16 6:29 
GeneralRe: Application download error in XBAP application after deploying the application Pin
Richard Deeming21-Sep-16 6:32
mveRichard Deeming21-Sep-16 6:32 
GeneralRe: Application download error in XBAP application after deploying the application Pin
indian14321-Sep-16 6:48
memberindian14321-Sep-16 6:48 
GeneralRe: Application download error in XBAP application after deploying the application Pin
Richard Deeming21-Sep-16 6:51
mveRichard Deeming21-Sep-16 6:51 
GeneralRe: Application download error in XBAP application after deploying the application Pin
indian14321-Sep-16 8:03
memberindian14321-Sep-16 8:03 
GeneralRe: Application download error in XBAP application after deploying the application Pin
Richard Deeming21-Sep-16 8:42
mveRichard Deeming21-Sep-16 8:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.