public void TwoWayBindingForAttachedProperty() { var viewModel = new TestViewModel() { }; using(var button = new Button()) { button.SetDataContext(viewModel); PropertyEntry<object> entry = CommandProvider.CommandParameterProperty.GetPropertyEntry(button); Assert.That(entry.ChangedSubscribeCount, Is.EqualTo(0)); button.SetBinding(CommandProvider.CommandParameterProperty, new Binding(() => viewModel.StringProperty, BindingMode.TwoWay)); Assert.That(entry.ChangedSubscribeCount, Is.EqualTo(1)); Assert.That(button.GetCommandParameter(), Is.Null); button.SetCommandParameter("test"); Assert.That(viewModel.StringProperty, Is.EqualTo("test")); button.ClearBinding(CommandProvider.CommandParameterProperty); Assert.That(entry.ChangedSubscribeCount, Is.EqualTo(0)); Assert.That(viewModel.StringProperty, Is.EqualTo("test")); Assert.That(button.GetCommandParameter(), Is.Null); viewModel.StringProperty = "test2"; Assert.That(button.GetCommandParameter(), Is.Null); button.SetCommandParameter("test3"); } }