Re: [Unity] Various questions
Posted: 21 May 2014, 12:24
To use extended classes in a xaml they have to derive from a serializable component (currently BaseComponent is not serializable but maybe we should change this to avoid confusion). So you have to change DataViewModel base class to Noesis.SerializableComponent:I tested your example and yes it works, thanks to the MonoBehaviour where you set the DataContext to the view model you created in code. I tried it the other way around, creating the view model within xaml and setting the data context in another grid. So I changed your example to fit my needs but then it didn't work any more. Is it even possible to do it this way as this would be a much neater solution?
Code: Select all
[Extended]
class DataViewModel : Noesis.SerializableComponent
{
string _title;
public string DataTitle
{
get { return _title; }
set
{
if (_title != value)
{
_title = value;
NotifyPropertyChanged("DataTitle");
}
}
}
Noesis.BaseComponent _child;
public Noesis.BaseComponent DataChild
{
get { return _child; }
set
{
if (_child != value)
{
_child = value;
NotifyPropertyChanged("DataChild");
}
}
}
}
Code: Select all
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid.Resources>
<DataViewModel x:Key="ViewModel" DataTitle="Some Window">
<DataViewModel.DataChild>
<StackPanel>
<TextBlock Text="Some text in the window" Margin="0,0,0,10"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Content="OK" Width="100"/>
<Button Content="Cancel" Width="100" Margin="8,0,0,0"/>
</StackPanel>
</StackPanel>
</DataViewModel.DataChild>
</DataViewModel>
</Grid.Resources>
<Grid DataContext="{StaticResource ViewModel}">
<WindowControl HorizontalAlignment="Center" VerticalAlignment="Center"
Title="{Binding DataTitle}"
Child="{Binding DataChild}"/>
</Grid>
</Grid>
We usually release a new version of NoesisGUI every 2/3 weeks containing improvement and fixes to bugs reported by customers. Then we submit that version to the Asset Store, that takes between 3 to 7 days, depending on their publishing queue, to be up in the web.@new version: How long does it usually take to get it released on Unity?