当前位置: 首页>>代码示例>>C#>>正文


C# StackPanel.SetBinding方法代码示例

本文整理汇总了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);
        }
开发者ID:ssethi,项目名称:TestFrameworks,代码行数:48,代码来源:UIBoundToCustomerWithContextNesting.cs

示例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);
        }
开发者ID:ssethi,项目名称:TestFrameworks,代码行数:22,代码来源:UIWithHierarchicalPath.cs

示例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");
		}
开发者ID:kangaroo,项目名称:moon,代码行数:13,代码来源:CollectionViewTest.cs


注:本文中的System.Windows.Controls.StackPanel.SetBinding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。