WeakReference DoCollectViewModel_TwoWay_AttachedProperty(TextBox textBox)
 {
     var viewModel = new TestViewModel();
     textBox.SetDataContext(viewModel);
     textBox.SetBinding(CommandProvider.CommandParameterProperty, new Binding(() => viewModel.StringProperty, BindingMode.TwoWay));
     return new WeakReference(viewModel);
 }
 WeakReference DoCollectTwoWayBoudnDataControl_AttachedProperty(TestViewModel viewModel)
 {
     var textBox = new TextBox();
     textBox.SetDataContext(viewModel);
     textBox.SetBinding(CommandProvider.CommandParameterProperty, new Binding(() => viewModel.StringProperty, BindingMode.TwoWay));
     return new WeakReference(textBox);
 }
        public void TwoWayBindingToUnstableProperty()
        {
            var viewModel = new UnstablePropertyViewModel() { };
            using(var textBox = new TextBox()) {
                textBox.SetDataContext(viewModel);

                textBox.SetBinding(() => textBox.Text, new Binding(() => viewModel.MyProperty, BindingMode.TwoWay));
                Assert.That(textBox.Text, Is.EqualTo(string.Empty));
                textBox.Text = "test";
                Assert.That(viewModel.MyProperty, Is.EqualTo("test_"));
                Assert.That(textBox.Text, Is.EqualTo("test_"));

            }
        }
 WeakReference DoCollectTwoWayBoudnDataControl(TestViewModel viewModel)
 {
     var textBox = new TextBox();
     textBox.SetDataContext(viewModel);
     textBox.SetBinding("Text", new Binding(() => viewModel.StringProperty, BindingMode.TwoWay));
     return new WeakReference(textBox);
 }
        public void TwoWayBindingDirectlyToDataContext()
        {
            var viewModel = "test";
            using(var textBox = new TextBox()) {
                textBox.SetDataContext(viewModel);
                Assert.Throws<InvalidOperationException>(() => {
                    textBox.SetBinding(() => textBox.Text, new Binding(string.Empty, BindingMode.TwoWay));
                }, SR.TwoWayBindingRequiresPathExceptionMessage);

            }
        }