- kemarofangs
- Posts: 32
- Joined:
Binding Issue
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.
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.
Code: Select all
<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
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?
-
sfernandez
Site Admin
- Posts: 3152
- Joined:
Re: Binding Issue
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).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.
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
- Posts: 32
- Joined:
Re: Binding Issue
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.
-
sfernandez
Site Admin
- Posts: 3152
- Joined:
Re: Binding Issue
It will be great if you can share your experience with NoesisGUI, by reviewing our package in the Unity Asset StoreThank 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.
-
sfernandez
Site Admin
- Posts: 3152
- Joined:
Re: Binding Issue
The problem with GridLength converter was solved in 1.1.9 version.
Who is online
Users browsing this forum: Ahrefs [Bot] and 3 guests