Mark Garcia
Mark Garcia

Reputation: 221

How to UWP Print ListView ItemTemplate

I'm trying to figure out how to print a ListView ItemTemplate using the uwp PrintHelper.cs sample. Everything works, except the print preview does not display items added to the ListView at runtime. I can add other controls such as a textbox, and the print preview will show it, so there must be something peculiar with printing databound ListView items at runtime, but I cannot find any information about it.

<ListView x:Name="ClipboardList"
                  xmlns:m="using:QuickieEdit.Models"
                  ItemsSource="{x:Bind ViewModel.MemoryItems}">
            <ListView.ItemTemplate>
                <DataTemplate x:DataType="m:MemoryItem">
                        <StackPanel Orientation="Horizontal">
                            <Button x:Name="MemoryCopyBtn"
                                         Content="Copy"
                                         Click="How to Copy currently selected
                                         MemoryListItem.Text?"/> 
                            <TextBox x:Name="MemoryListItem"
                                           Text="{x:Bind Memory, Mode=TwoWay}">
                           </TextBox>                                  
                       </StackPanel>
                </DataTemplate>
            </ListView.ItemTemplate>

Upvotes: 0

Views: 502

Answers (1)

Viral Parmar
Viral Parmar

Reputation: 112

I cannot understand your exact query, but I think you may be facing situation where your ListView does not get updated with the model and hence does not show up while printing. You can use ObservableCollection<Model> instead of List<Model>

This will solve your problem or if it does not please provide the c# code in detail as well Cheers

Upvotes: 1

Related Questions