I have user control with a fixed page element, everything works fine from the UI but when I print it the data in the listview is not printed on the receipt I tried several things but no matter what it just doesn't show up.
Here is the XAML
<FixedPage x:Name="ReceiptData">
<StackPanel Orientation="Vertical">
<Image Source="../Images/LOGO.png" Width="340" Margin="5,1,1,1"></Image>
<StackPanel Orientation="Horizontal" >
<Label Margin="5,1,0,1" Content="{Binding KioskName, FallbackValue=000000}"></Label>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="Date:" Margin="5,1,8,1"></Label>
<Label Content="{Binding CurrentDateTime, StringFormat=g}"></Label>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Border BorderThickness="0,1,0,0"
BorderBrush="Black"
Height="5" Width="345"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="Qauntity"></Label>
<Label Content="Description" Margin="8,0,0,0"></Label>
<Label Content="Price" Margin="130,0,0,0"></Label>
</StackPanel>
<ListView ItemsSource="{Binding SaleItemsObservable}" MinHeight="300"
BorderBrush="{x:Null}"
Background="{x:Null}"
Foreground="Black">
<ListView.View>
<GridView ColumnHeaderContainerStyle="{StaticResource gridViewNoHeader}">
<GridViewColumn DisplayMemberBinding="{Binding Quantity}" Width="45"/>
<GridViewColumn DisplayMemberBinding="{Binding ProductName}" Width="210" />
<GridViewColumn DisplayMemberBinding="{Binding Path=Price, StringFormat='{}{0:c}'}" Width="55"/>
</GridView>
</ListView.View>
</ListView>
<Image Source="../Images/LOGO.png" Width="340" Margin="5,1,1,1"></Image>
</StackPanel>
</FixedPage>
This is the code that prints it.
private void Button_Click(object sender, RoutedEventArgs e)
{
InnerGrid.Children.Remove(ReceiptData);
PrintQueue sourcePrintQueue = new LocalPrintServer().DefaultPrintQueue;
if (sourcePrintQueue != null)
{
var pageContent = new PageContent();
var fixedDocument = new FixedDocument();
fixedDocument.PrintTicket = new PrintTicket();
var printTicket = (PrintTicket)fixedDocument.PrintTicket;
printTicket.PageOrientation = PageOrientation.Portrait;
((IAddChild)pageContent).AddChild(ReceiptData);
fixedDocument.Pages.Add(pageContent);
PrintDialog pd = new PrintDialog();
pd.PrintQueue = sourcePrintQueue;
pd.PrintTicket = printTicket;
pd.PrintDocument(fixedDocument.DocumentPaginator, "Kiosk 2.0 Receipt");
}
}
It prints perfectly fine but the data in the listview is missing no matter what, I have tried setting a template, I have tried manually setting the items in the code behind but nothing works so I assume there is something I am missing to tell it to render that data to the printer? Any ideas?