public void ValidateConversionToDependencyPropertyWithOptions() { Type type = _assembly.GetType("PropertyAttribute"); DependencyProperty valueProperty = (DependencyProperty)type.GetField("WithOptionsProperty").GetValue(null); WithOptionsViewModel viewModel = new WithOptionsViewModel(); Binding binding = new Binding(nameof(WithOptionsViewModel.Source)) { Source = viewModel }; BindingOperations.SetBinding(_object, valueProperty, binding); _object.SetValue(valueProperty, 1); Assert.AreEqual(1, viewModel.Source); }
public void ValidateConversionToDependencyPropertyWithOptions() { Type type = _assembly.GetType("PropertyAttribute"); DependencyProperty valueProperty = (DependencyProperty)type.GetField("WithOptionsProperty").GetValue(null); dynamic instance = Activator.CreateInstance(type); WithOptionsViewModel viewModel = new WithOptionsViewModel(); Binding binding = new Binding(nameof(WithOptionsViewModel.Source)) { Source = viewModel }; BindingOperations.SetBinding(instance, valueProperty, binding); instance.WithOptions = 2; Assert.AreEqual(2, viewModel.Source); }