Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

ListView.ItemsPanel is not created

$
0
0

I have a UserControl named 'GridPage' that contains ListView with Grid as ItemsPanel:

<UserControlx:Class="StoreManager.VirtuePrint.GridPage"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"mc:Ignorable="d"d:DesignWidth="300"d:DesignHeight="300"Width="21cm"Height="29.7cm"><ListViewName="listView"Width="21cm"Height="29.7cm"><ListView.Template><ControlTemplate><ItemsPresenter/></ControlTemplate></ListView.Template><ListView.ItemsPanel><ItemsPanelTemplate><GridShowGridLines="True"IsItemsHost="True"Background="White"/></ItemsPanelTemplate></ListView.ItemsPanel><ListView.ItemTemplate><DataTemplate><LabelContent="{Binding InnerView.Entity.Name}"HorizontalAlignment="Center"VerticalAlignment="Center"/></DataTemplate></ListView.ItemTemplate><ListView.ItemContainerStyle><Style><Setter Property="Grid.Column" Value="{Binding Column}"/><Setter Property="Grid.Row" Value="{Binding Row}"/></Style></ListView.ItemContainerStyle></ListView></UserControl>

it works fine if I create it as normal control inside some Window, but when I try to print it using DocumentPaginator with the following code:

classGridPaginator:DocumentPaginator{....publicoverrideDocumentPageGetPage(int pageNumber){GridPage grid =newGridPage(){Width= pageLayout.PaperSizeInPixels.Width,Height= pageLayout.PaperSizeInPixels.Height};...

        grid.Measure(pageLayout.PaperSizeInPixels);

        grid.Arrange(newRect(newPoint(0,0), pageLayout.PaperSizeInPixels));//finally return the pagereturnnewDocumentPage(grid);}...}

Grid's Loaded event does not fire and ListView.ItemsPanel is not created (((System.Windows.Controls.ItemsControl)(listView))._itemsHost is null). ListView exists (not null) but it does not have ItemsPanel in this case.

I tried grid.InvalidateVisual() but it does not help.

What can cause this situation?


Dmitriano http://developernote.com


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>