本文整理汇总了C#中System.Windows.Controls.StackPanel.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# StackPanel.SetBinding方法的具体用法?C# StackPanel.SetBinding怎么用?C# StackPanel.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.StackPanel
的用法示例。
在下文中一共展示了StackPanel.SetBinding方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UIBoundToCustomerWithContextNesting
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);
}
示例2: UIWithHierarchicalPath
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);
}
示例3: BindToICV__ICVProperty
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");
}