Note that there are some explanatory texts on larger screens.

plurals
  1. POExport ListView Data to Image in WPF
    text
    copied!<p>I am trying to export listview data to an image. I can not use <strong>PrintVisual</strong> method because the listview is scrollable, the listview can be rtl or ltr and <strong>PrintVisual</strong> does not support rtl listview as I have tested.</p> <p>This is my ListView</p> <pre><code>&lt;ListView Name="TimeListView" Height="359" Width="470"&gt; &lt;ListView.ItemContainerStyle&gt; &lt;Style TargetType="{x:Type ListViewItem}"&gt; &lt;Setter Property="Margin" Value="0,0,0,0"/&gt; &lt;Setter Property="Padding" Value="0,2"/&gt; &lt;Setter Property="BorderBrush" Value="LightGray"/&gt; &lt;Setter Property="BorderThickness" Value="0,0,0,1"/&gt; &lt;Setter Property="HorizontalContentAlignment" Value="Stretch"/&gt; &lt;Setter Property="VerticalContentAlignment" Value="Stretch"&gt;&lt;/Setter&gt; &lt;/Style&gt; &lt;/ListView.ItemContainerStyle&gt; &lt;ListView.View&gt; &lt;GridView&gt; &lt;GridViewColumn x:Name="DayCol" Header="{Binding ElementName=TimeListView, Path=DataContext.DayHeader}" Width="40"&gt; &lt;GridViewColumn.CellTemplate&gt; &lt;DataTemplate&gt; &lt;Border BorderBrush="LightGray" BorderThickness="0,0,1,0" Margin="-6,-2,-6,-2"&gt; &lt;StackPanel Margin="6,2,6,2"&gt; &lt;TextBlock Text="{Binding Path=Days}"&gt;&lt;/TextBlock&gt; &lt;/StackPanel&gt; &lt;/Border&gt; &lt;/DataTemplate&gt; &lt;/GridViewColumn.CellTemplate&gt; &lt;/GridViewColumn&gt; &lt;GridViewColumn x:Name="FCol" Header="{Binding ElementName=TimeListView, Path=DataContext.FajirHeader}" Width="68"&gt; &lt;GridViewColumn.CellTemplate&gt; &lt;DataTemplate&gt; &lt;Border BorderBrush="LightGray" BorderThickness="0,0,1,0" Margin="-6,-2,-6,-2"&gt; &lt;StackPanel Margin="6,2,6,2"&gt; &lt;TextBlock Text="{Binding Path=FT}"&gt;&lt;/TextBlock&gt; &lt;/StackPanel&gt; &lt;/Border&gt; &lt;/DataTemplate&gt; &lt;/GridViewColumn.CellTemplate&gt; &lt;/GridViewColumn&gt; &lt;GridViewColumn x:Name="SCol" Header="{Binding ElementName=TimeListView, Path=DataContext.SunriseHeader}" Width="68"&gt; &lt;GridViewColumn.CellTemplate&gt; &lt;DataTemplate&gt; &lt;Border BorderBrush="LightGray" BorderThickness="0,0,1,0" Margin="-6,-2,-6,-2"&gt; &lt;StackPanel Margin="6,2,6,2"&gt; &lt;TextBlock Text="{Binding Path=ST}"&gt;&lt;/TextBlock&gt; &lt;/StackPanel&gt; &lt;/Border&gt; &lt;/DataTemplate&gt; &lt;/GridViewColumn.CellTemplate&gt; &lt;/GridViewColumn&gt; &lt;GridViewColumn x:Name="DCol" Header="{Binding ElementName=TimeListView, Path=DataContext.DhuhrHeader}" Width="68"&gt; &lt;GridViewColumn.CellTemplate&gt; &lt;DataTemplate&gt; &lt;Border BorderBrush="LightGray" BorderThickness="0,0,1,0" Margin="-6,-2,-6,-2"&gt; &lt;StackPanel Margin="6,2,6,2"&gt; &lt;TextBlock Text="{Binding Path=DT}"&gt;&lt;/TextBlock&gt; &lt;/StackPanel&gt; &lt;/Border&gt; &lt;/DataTemplate&gt; &lt;/GridViewColumn.CellTemplate&gt; &lt;/GridViewColumn&gt; &lt;GridViewColumn x:Name="ACol" Header="{Binding ElementName=TimeListView, Path=DataContext.AsrHeader}" Width="68"&gt; &lt;GridViewColumn.CellTemplate&gt; &lt;DataTemplate&gt; &lt;Border BorderBrush="LightGray" BorderThickness="0,0,1,0" Margin="-6,-2,-6,-2"&gt; &lt;StackPanel Margin="6,2,6,2"&gt; &lt;TextBlock Text="{Binding Path=AT}"&gt;&lt;/TextBlock&gt; &lt;/StackPanel&gt; &lt;/Border&gt; &lt;/DataTemplate&gt; &lt;/GridViewColumn.CellTemplate&gt; &lt;/GridViewColumn&gt; &lt;GridViewColumn x:Name="MCol" Header="{Binding ElementName=TimeListView, Path=DataContext.MaghribHeader}" Width="68"&gt; &lt;GridViewColumn.CellTemplate&gt; &lt;DataTemplate&gt; &lt;Border BorderBrush="LightGray" BorderThickness="0,0,1,0" Margin="-6,-2,-6,-2"&gt; &lt;StackPanel Margin="6,2,6,2"&gt; &lt;TextBlock Text="{Binding Path=MT}"&gt;&lt;/TextBlock&gt; &lt;/StackPanel&gt; &lt;/Border&gt; &lt;/DataTemplate&gt; &lt;/GridViewColumn.CellTemplate&gt; &lt;/GridViewColumn&gt; &lt;GridViewColumn x:Name="ICol" Header="{Binding ElementName=TimeListView, Path=DataContext.IshaHeader}" Width="68"&gt; &lt;GridViewColumn.CellTemplate&gt; &lt;DataTemplate&gt; &lt;Border BorderBrush="LightGray" BorderThickness="0,0,1,0" Margin="-6,-2,-6,-2"&gt; &lt;StackPanel Margin="6,2,6,2"&gt; &lt;TextBlock Text="{Binding Path=IsT}"&gt;&lt;/TextBlock&gt; &lt;/StackPanel&gt; &lt;/Border&gt; &lt;/DataTemplate&gt; &lt;/GridViewColumn.CellTemplate&gt; &lt;/GridViewColumn&gt; &lt;/GridView&gt; &lt;/ListView.View&gt; &lt;/ListView&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload