You can do it with the creation of one custom class, so that is one hoop, but the hoop doesn't know about anything in your Xaml...
public class DoubleCache : INotifyPropertyChanged {
public event PropertyChangedEventHandler PropertyChanged;
private double _Value;
public double Value {
get { return _Value; }
set {
_Value = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("Value"));
}
}
}
Then you can set up the actual bindings in Xaml...
shacktoms
Member
185 Points
155 Posts
Re: Data Binding broken in SLv2 Beta2
Sep 04, 2008 06:04 PM | LINK
You can do it with the creation of one custom class, so that is one hoop, but the hoop doesn't know about anything in your Xaml...
public class DoubleCache : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; private double _Value; public double Value { get { return _Value; } set { _Value = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Value")); } } }Then you can set up the actual bindings in Xaml...
<UserControl x:Class="TwoSliders.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:TwoSliders;assembly=TwoSliders" Width="400" Height="300"> <StackPanel x:Name="LayoutRoot" Background="White"> <StackPanel.Resources> <local:DoubleCache x:Key="SliderPosition"/> </StackPanel.Resources> <Slider Value="{Binding Value, Mode=TwoWay, Source={StaticResource SliderPosition}}"/> <Slider Value="{Binding Value, Mode=TwoWay, Source={StaticResource SliderPosition}}"/> </StackPanel> </UserControl>