[Unity] Nested Data Bindings
Posted: 24 Sep 2014, 01:39
Hi,
I am trying to bind user controls nested within user controls, and it does not seem to be working.
Example:
DetailCardView.xaml
AtAGlanceView.xaml
Test.cs
So this works fine in DetailCardView, and the bindings work for the textblocks there, but does not work for the AtAGlance control. Is there something I'm missing here?
I am trying to bind user controls nested within user controls, and it does not seem to be working.
Example:
DetailCardView.xaml
Code: Select all
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vs="clr-namespace:Assets.UI.VirtualShelf"
xmlns:vm="clr-namespace:Assets.UI.ViewModels.VirtualShelf"
x:Name="Root"
x:Class="Assets.UI.VirtualShelf.DetailCardView"
Margin="0,0,0,0">
<Grid>
<StackPanel>
<TextBlock Text="{Binding Category}"></TextBlock>
<TextBlock Text="{Binding AtAGlance.Name}"></TextBlock>
<vs:AtAGlanceView
DataContext="{Binding AtAGlance}"
Width="{Binding ActualWidth, ElementName=Root, Mode=OneWay}"
Height="{Binding ActualHeight, ElementName=Root, Mode=OneWay}" />
</StackPanel
</Grid>
</UserControl>
Code: Select all
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Assets.UI.VirtualShelf.AtAGlanceView">
<Grid Background="White">
<TextBlock Text="{Binding Name}" />
</Grid>
</UserControl>
Code: Select all
public class DetailCardViewTestComponent : MonoBehaviour
{
public void Start()
{
var detailCard = GetComponent<NoesisGUIPanel>().GetRoot<DetailCardView>();
var vm = new DetailCardViewModel
{
Category = "Foo",
AtAGlance = new AtAGlanceViewModel
{
Name = "Bar"
}
};
}
}