Assume that we have example noesis project with view model like below...
#if UNITY_5_3_OR_NEWER
using Noesis;
using UniRxNoesisBridge;
#else
using System.Windows.Media;
#endif
namespace UI {
/// <summary>
/// Interaction logic for application ViewModel
/// </summary>
public partial class ViewModel {
public BindableReactiveProperty<Color> TopColor { get; set; }
//public Color TopColor { get; set; }
public Color BottomColor { get; set; }
public ViewModel() {
TopColor = new BindableReactiveProperty<Color>(Color.FromRgb(16, 102, 157), "TopColor.Value");
TopColor.Value = Color.FromRgb(16, 0, 0);
//TopColor = Color.FromRgb(17, 102, 157);
BottomColor = Color.FromRgb(18, 57, 87);
int i = 0;
}
}
}
and code-behind of MainWindow ...
#if UNITY_5_3_OR_NEWER
#define NOESIS
using Noesis;
#else
using System;
using System.Windows;
using System.Windows.Controls;
#endif
namespace UI {
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : UserControl {
public MainWindow() {
InitializeComponent();
DataContext = new ViewModel();
}
#if NOESIS
private void InitializeComponent() {
Noesis.GUI.LoadComponent(this, "Assets/NoesisGUI/Sample/MainWindow.xaml");
}
#endif
}
}
We have to bind to <variable_name>.Value to get any messages about changed value
<UserControl x:Class="UI.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Grid.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0" Color="{Binding TopColor.Value}"/>
<GradientStop Offset="1" Color="{Binding BottomColor}"/>
</LinearGradientBrush>
</Grid.Background>
<Viewbox>
<TextBlock Text="Hello World!" Foreground="White" Margin="100"/>
</Viewbox>
</Grid>
</UserControl>