Reputation: 1182
Our application was previously designed for Windows 8.1. We are now looking into porting it to Universal Windows Apps for Windows 10.
We have noticed a difference in behavior, specifically with ListView / ItemsControl.
The weird thing is, for the 2nd bullet, changing it to GridView solves the margin problem. 1st bullet still remains though.
Has anyone else encountered this and how did you solve it?
Thank you
Edit: Code for reference:
<GridView Grid.Row="1"
ItemsSource="{Binding Path=Tables}">
<GridView.ItemContainerStyle>
<Style TargetType="GridViewItem">
<Setter Property="VerticalContentAlignment" Value="Top" />
<Setter Property="Margin" Value="0" />
</Style>
</GridView.ItemContainerStyle>
<GridView.ItemTemplate>
<DataTemplate>
<Grid Visibility="{Binding Path=ShowTable, Converter={StaticResource BoolToVisConverter}}">
<!-- A lot of UI Element -->
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsStackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
This is my code. I have traced it and the Visibility for the Grid is working correctly (true / false, sets visibility correctly). The problem is, even if the "Grid" is hidden, the "GridViewItem" seems to still eat up space. It seems that the Width doesn't change for the GridViewItem. On Windows 8.1 app, there are no spaces.
Is this a bug?
Upvotes: 1
Views: 78
Reputation: 3568
GridViewItems have a default MinWidth
defined. You have to remove it in the ItemContainerStyle
. You can check the default template here.
<Setter Property="MinWidth" Value="0" />
I could not reproduce your additional margin problem. With the code shown above, all elements in the List appeared adjacent to each other.
Upvotes: 3