kemarofangs
Topic Author
Posts: 32
Joined: 13 Jun 2014, 21:30

Binding Issue

13 Jun 2014, 21:45

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>
 
User avatar
Scherub
Posts: 141
Joined: 06 May 2014, 20:53
Contact:

Re: Binding Issue

15 Jun 2014, 02:36

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

Re: Binding Issue

16 Jun 2014, 17:07

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.
 
kemarofangs
Topic Author
Posts: 32
Joined: 13 Jun 2014, 21:30

Re: Binding Issue

16 Jun 2014, 19:15

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

Re: Binding Issue

16 Jun 2014, 20:01

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

Re: Binding Issue

01 Jul 2014, 14:43

The problem with GridLength converter was solved in 1.1.9 version.

Who is online

Users browsing this forum: No registered users and 0 guests