Page 1 of 1

Binding Issue

Posted: 13 Jun 2014, 21:45
by kemarofangs
Hello All,

I'm having trouble trying to get a simple binding to work. This code works fine in visual studio / blend and allocates only enough space for the row to house the label element. However, In unity, the same code makes the label take up half the grid. Am I doing something wrong? Is this a bug? Should I be going about this a different way? I really do not want to hard code a number.
<Grid>
	<Grid.RowDefinitions>
        	<RowDefinition Height="{Binding Path=Height, ElementName=m_label}" />
                <RowDefinition />
	</Grid.RowDefinitions>
	<Label Grid.Row="0" x:Name="m_label" Content="Test" />
</Grid>

Re: Binding Issue

Posted: 15 Jun 2014, 02:36
by Scherub
I'm curious what's the reason behind binding the height of your first row-definition to the label instead of setting it to 'Auto'. For this simple case I see no point in doing it this way but perhaps you have a more complex example where this would be required?

Re: Binding Issue

Posted: 16 Jun 2014, 17:07
by sfernandez
I'm having trouble trying to get a simple binding to work. This code works fine in visual studio / blend and allocates only enough space for the row to house the label element. However, In unity, the same code makes the label take up half the grid. Am I doing something wrong? Is this a bug? Should I be going about this a different way? I really do not want to hard code a number.
As Scherub indicated your example is equivalent to having a RowDefinition with Height="Auto", because the default value for the Height property of any UI element is Auto (NaN).

Anyway, as you experienced, there is a bug in the GridLength converter. It is ignoring the NaN value, so the conversion fails, and default RowDefinition.Height value is used (that is "*"). We will fix it for the next release.

Re: Binding Issue

Posted: 16 Jun 2014, 19:15
by kemarofangs
Thank you both for the "Auto" suggestion. It works great. I feel kinda dumb for not knowing a simpler way to do the same thing. This product really is the best GUI for Unity IMO and I appreciate all the hard work going into it.

Re: Binding Issue

Posted: 16 Jun 2014, 20:01
by sfernandez
Thank you both for the "Auto" suggestion. It works great. I feel kinda dumb for not knowing a simpler way to do the same thing. This product really is the best GUI for Unity IMO and I appreciate all the hard work going into it.
It will be great if you can share your experience with NoesisGUI, by reviewing our package in the Unity Asset Store ;)

Re: Binding Issue

Posted: 01 Jul 2014, 14:43
by sfernandez
The problem with GridLength converter was solved in 1.1.9 version.