User avatar
Scherub
Topic Author
Posts: 141
Joined: 06 May 2014, 20:53
Contact:

[Unity] Alternative for UniformGrid

14 Jun 2015, 20:51

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?
 
User avatar
sfernandez
Site Admin
Posts: 1911
Joined: 22 Dec 2011, 19:20

Re: [Unity] Alternative for UniformGrid

15 Jun 2015, 19:07

I can think of a solution using WrapPanels and bindings to determine the appropriate cell size using Grid with relative sizes, for example:
<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>
Will this work for you?
 
User avatar
Scherub
Topic Author
Posts: 141
Joined: 06 May 2014, 20:53
Contact:

Re: [Unity] Alternative for UniformGrid

17 Jun 2015, 12:26

Hi and thanks for your answer. Your solution gave me a good starting point! :)
 
User avatar
jsantos
Site Admin
Posts: 2903
Joined: 20 Jan 2012, 17:18
Contact:

Re: [Unity] Alternative for UniformGrid

03 Jul 2015, 13:09

UniformGrid is planned (in fact already implemented) for v1.2.4

Who is online

Users browsing this forum: No registered users and 1 guest