[Unity] Alternative for UniformGrid
Hi,
right now I'm trying to create an inventory for a mobile application. Up until now I used an ItemsControl with a WrapPanel for its elements (similar to this video). The problem with that is that I need to define the cell size dependent on the actual resolution (and ppi). And if you think of mobile devices there are 'hundreds' of different resolutions.
Instead I would prefer to use a UniformGrid. Unfortunately it's not implemented yet. Do you have a good idea how I could achieve the same behaviour with any other Panel under Unity?
right now I'm trying to create an inventory for a mobile application. Up until now I used an ItemsControl with a WrapPanel for its elements (similar to this video). The problem with that is that I need to define the cell size dependent on the actual resolution (and ppi). And if you think of mobile devices there are 'hundreds' of different resolutions.
Instead I would prefer to use a UniformGrid. Unfortunately it's not implemented yet. Do you have a good idea how I could achieve the same behaviour with any other Panel under Unity?
-
sfernandez
Site Admin
- Posts: 3184
- Joined:
Re: [Unity] Alternative for UniformGrid
I can think of a solution using WrapPanels and bindings to determine the appropriate cell size using Grid with relative sizes, for example:
Will this work for you?
Code: Select all
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid x:Name="reference">
<Grid.RowDefinitions>
<RowDefinition Height="1*"/> <!-- 10% of screen height -->
<RowDefinition Height="9*"/>
</Grid.RowDefinitions>
<Decorator x:Name="cellSize" Grid.Row="0"/>
</Grid>
<WrapPanel
ItemWidth="{Binding ActualHeight, ElementName=cellSize}"
ItemHeight="{Binding ActualHeight, ElementName=cellSize}">
...
</WrapPanel>
</Grid>
Re: [Unity] Alternative for UniformGrid
Hi and thanks for your answer. Your solution gave me a good starting point!
Re: [Unity] Alternative for UniformGrid
UniformGrid is planned (in fact already implemented) for v1.2.4
Who is online
Users browsing this forum: No registered users and 7 guests