public UIBoundToCustomerWithContextNesting() { var stack = new StackPanel(); Content = stack; var textBlock = new TextBlock(); textBlock.SetBinding(TextBlock.TextProperty, new Binding("FirstName")); stack.Children.Add(textBlock); textBlock = new TextBlock(); textBlock.SetBinding(TextBlock.TextProperty, new Binding("LastName")); stack.Children.Add(textBlock); var addressStack = new StackPanel(); addressStack.SetBinding(StackPanel.DataContextProperty, new Binding("MailingAddress")); stack.Children.Add(addressStack); textBlock = new TextBlock(); textBlock.SetBinding(TextBlock.TextProperty, new Binding("Street")); //misspelling addressStack.Children.Add(textBlock); textBlock = new TextBlock(); textBlock.SetBinding(TextBlock.TextProperty, new Binding("Something")); //does not exist addressStack.Children.Add(textBlock); textBlock = new TextBlock(); textBlock.SetBinding(TextBlock.TextProperty, new Binding("Street2")); addressStack.Children.Add(textBlock); addressStack = new StackPanel(); addressStack.SetBinding(StackPanel.DataContextProperty, new Binding("BllingAddress")); //misspelled stack.Children.Add(addressStack); textBlock = new TextBlock(); textBlock.SetBinding(TextBlock.TextProperty, new Binding("Street")); //misspelling addressStack.Children.Add(textBlock); textBlock = new TextBlock(); textBlock.SetBinding(TextBlock.TextProperty, new Binding("Something")); //does not exist addressStack.Children.Add(textBlock); textBlock = new TextBlock(); textBlock.SetBinding(TextBlock.TextProperty, new Binding("Street2")); addressStack.Children.Add(textBlock); }
public UIWithHierarchicalPath() { var grid = new Grid(); Content = grid; var label = new Label(); label.SetBinding(Label.ContentProperty, new Binding("Items/Description")); grid.Children.Add(label); var stack = new StackPanel(); stack.SetBinding(StackPanel.DataContextProperty, new Binding("Items")); grid.Children.Add(stack); label = new Label(); label.SetBinding(Label.ContentProperty, new Binding("/Description")); stack.Children.Add(label); var button = new Button(); button.SetBinding(Button.ContentProperty, new Binding("/")); button.Template = CreateTemplate(); stack.Children.Add(button); }
public void BindToICV__ICVProperty () { var HostPanel = new StackPanel (); var collection = new ObservableCollection<int> () { 1, 2, 5, 0 }; var cvs = new CollectionViewSource () { Source = collection }; var binding = new Binding ("IsCurrentAfterLast") { Source = cvs.View, BindsDirectlyToSource = false }; HostPanel.SetBinding (Panel.TagProperty, binding); Assert.IsNotNull (HostPanel.Tag, "#4"); }