// [TestMethod] // TODO public void BindCollection() { //PersonVM vm = null; PersonVMView view = new PersonVMView(); DataGrid grid = new DataGrid(); var nameColumn = new DataGridTextColumn(); var memberCountColumn = new DataGridTextColumn(); grid.Columns.Add(nameColumn); grid.Columns.Add(memberCountColumn); ViewBinder.BindVM(view, b => { b.Collection(x => x.Projects).To(grid, i => { i.Property(x => x.Name).To(nameColumn); i.Property(x => x.MemberCount).To(memberCountColumn); }); }); Binding itemsSourceBinding = BindingOperations.GetBinding(grid, DataGrid.ItemsSourceProperty); Assert.IsNotNull(itemsSourceBinding); Assert.IsNull(itemsSourceBinding.Source); Assert.AreEqual("Projects", itemsSourceBinding.Path.Path); Binding nameBinding = (Binding)nameColumn.Binding; Binding memberCountBinding = (Binding)memberCountColumn.Binding; Assert.AreEqual("Name", nameBinding.Path.Path); Assert.AreEqual("MemberCount", memberCountBinding.Path.Path); Assert.IsNull(nameBinding.Source); Assert.IsNull(memberCountBinding.Source); }
public void KeyGesture_IsAddedToInputBindingsOfTargetObject() { var target = new Button(); var view = new TestView(); ViewBinder.BindVM(view, b => { b.Property(x => x.ViewModelCommand).To(target).KeyGesture(Key.A, ModifierKeys.Control); }); Assert.AreEqual(1, target.InputBindings.Count); var inputBinding = (KeyBinding)target.InputBindings[0]; Assert.AreEqual(Key.A, inputBinding.Key); var binding = BindingOperations.GetBinding(inputBinding, KeyBinding.CommandProperty); Assert.AreEqual("ViewModelCommand", binding.Path.Path); }