Question

I am displaying Calendar to the user from My WPF application. I have the Observable collection and binding these collections from the viewmodel.In Order to display as like Calendar (first 7 columns in first row, second 7 columns in the next rows ect),I am using "Wrap Panel".The Below code works perfectly in Windows 7.But When I tried to run this in Windows 8,I can see Only the first 5 columns are displaying in a Row. How can I solvemit?Is there any problem for Wrap Panel Width in Windows 8 Os?

 <ListBox x:Name="lstIcon" Grid.Row="1" ItemsSource="{Binding CalenderDatalist}"   Background="#FFF9F9F9" >        
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel Orientation="Horizontal" Width="245">
                    </WrapPanel>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Vertical" Width="33" Height="60">
                        <TextBlock Width="15" Text="{Binding Day}" HorizontalAlignment="Left" VerticalAlignment="Center"  FontSize="10" Foreground="Red" />
                        <StackPanel Background="{Binding IsDropped,Converter={StaticResource BooleanToBackgroundConvertor}}" >
                            <TextBlock Width="25" Text="{Binding From}" HorizontalAlignment="Left" VerticalAlignment="Center"  FontSize="10" />
                            <TextBlock Width="25" Text="{Binding To}" HorizontalAlignment="Left" VerticalAlignment="Center"  FontSize="10" />
                            <TextBlock Width="25" Text="{Binding Time}" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="10" />
                        </StackPanel>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
Was it helpful?

Solution

Since your DataTemplate items are having fixed size, set ItemWidth property to WrapPanel. Like,

<WrapPanel Orientation="Horizontal" Width="245" ItemWidth="33">
</WrapPanel>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top