Browse Source

Merge pull request #527 from wieslawsoltes/Issue526

Fix for issue #526
pull/528/head
Steven Kirk 11 years ago
parent
commit
75801a0b34
  1. 9
      samples/BindingTest/MainWindow.xaml
  2. 6
      samples/BindingTest/ViewModels/MainWindowViewModel.cs
  3. 1
      src/Perspex.Controls/Primitives/ToggleButton.cs

9
samples/BindingTest/MainWindow.xaml

@ -68,5 +68,14 @@
</ContentControl>
</StackPanel>
</TabItem>
<TabItem Header="Commands">
<StackPanel Margin="18" Gap="4" Width="200">
<Button Content="Button" Command="{Binding StringValueCommand}" CommandParameter="Button"/>
<ToggleButton Content="ToggleButton" Command="{Binding StringValueCommand}" CommandParameter="ToggleButton"/>
<CheckBox Content="CheckBox" Command="{Binding StringValueCommand}" CommandParameter="CheckBox"/>
<RadioButton Content="RadionButton" Command="{Binding StringValueCommand}" CommandParameter="RadioButton"/>
<TextBox Text="{Binding Path=StringValue}"/>
</StackPanel>
</TabItem>
</TabControl>
</Window>

6
samples/BindingTest/ViewModels/MainWindowViewModel.cs

@ -2,6 +2,7 @@
using System.Collections.ObjectModel;
using System.Linq;
using ReactiveUI;
using System.Reactive.Linq;
namespace BindingTest.ViewModels
{
@ -28,6 +29,9 @@ namespace BindingTest.ViewModels
var r = new Random();
Items.Move(r.Next(Items.Count), 1);
});
StringValueCommand = ReactiveCommand.Create();
StringValueCommand.Subscribe(param => StringValue = param.ToString());
}
public ObservableCollection<TestItem> Items { get; }
@ -51,5 +55,7 @@ namespace BindingTest.ViewModels
get { return _stringValue; }
set { this.RaiseAndSetIfChanged(ref _stringValue, value); }
}
public ReactiveCommand<object> StringValueCommand { get; }
}
}

1
src/Perspex.Controls/Primitives/ToggleButton.cs

@ -31,6 +31,7 @@ namespace Perspex.Controls.Primitives
protected override void OnClick(RoutedEventArgs e)
{
base.OnClick(e);
Toggle();
}

Loading…
Cancel
Save