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


C# ContentControl.SetBinding方法代码示例

本文整理汇总了C#中Windows.UI.Xaml.Controls.ContentControl.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# ContentControl.SetBinding方法的具体用法?C# ContentControl.SetBinding怎么用?C# ContentControl.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.UI.Xaml.Controls.ContentControl的用法示例。


在下文中一共展示了ContentControl.SetBinding方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: scrollViewer_Loaded

        private void scrollViewer_Loaded(object sender, RoutedEventArgs e)
        {
            scrollViewer.Loaded -= scrollViewer_Loaded;
            scrollViewer.ViewChanged += ScrollViewer_ViewChanged;

            currentTopGroupHeader = this.scrollViewer.FindDescendantByName("TopGroupHeader") as ContentControl;
            Binding binding = new Binding();
            binding.Source = this;
            binding.Mode = BindingMode.OneWay;
            binding.Path = new PropertyPath("GroupHeaderTemplate");
            currentTopGroupHeader.SetBinding(ContentControl.ContentTemplateProperty, binding);
            currentTopGroupHeader.Visibility = Visibility.Collapsed;
            if (scrollViewer.VerticalOffset == 0)
            {
                CreateVisual();
            }
            else
            {
                scrollViewer.RegisterPropertyChangedCallback(ScrollViewer.VerticalOffsetProperty, new DependencyPropertyChangedCallback(OnScrollViewerVerticalOffsetChanged));
            }
        }
开发者ID:GJian,项目名称:UWP-master,代码行数:21,代码来源:GroupListView1.cs

示例2: UpdateSelectedValue

        /// <summary>
        /// Update the selected value of the of the TreeView based on the value
        /// of the currently selected TreeViewItem and the SelectedValuePath.
        /// </summary>
        /// <param name="item">
        /// Value of the currently selected TreeViewItem.
        /// </param>
        private void UpdateSelectedValue(object item)
        {
            if (item != null)
            {
                string path = SelectedValuePath;
                if (string.IsNullOrEmpty(path))
                {
                    SelectedValue = item;
                }
                else
                {
                    // Since we don't have the ability to evaluate a
                    // BindingExpression, we'll just create a new temporary
                    // control to bind the value to which we can then copy out
                    Binding binding = new Binding
                                      {
                                          Path = new PropertyPath(path),
                                          Source = item
                                      };
                    ContentControl temp = new ContentControl();
                    temp.SetBinding(ContentControl.ContentProperty, binding);
                    SelectedValue = temp.Content;

                    // Remove the Binding once we have the value (this is
                    // especially important if the value is a UIElement because
                    // it should not exist in the visual tree once we've
                    // finished)
                    temp.ClearValue(ContentControl.ContentProperty);
                }
            }
            else
            {
                ClearValue(SelectedValueProperty);
            }
        }
开发者ID:karpinsn,项目名称:AntStrength,代码行数:42,代码来源:TreeView.cs

示例3: ControlWithExistingBindingOnContentWithNullValueThrows

        public async Task ControlWithExistingBindingOnContentWithNullValueThrows()
        {
            await ExecuteOnUIThread(() =>
                {
                    var control = new ContentControl();
                    Binding binding = new Binding
                    {
                        Path = new PropertyPath("ObjectContents"),
                        Source = new SimpleModel() { ObjectContents = null }
                    };
                    control.SetBinding(ContentControl.ContentProperty, binding);

                    IRegionAdapter adapter = new TestableContentControlRegionAdapter();

                    Assert.ThrowsException<InvalidOperationException>(
                        () => (MockPresentationRegion)adapter.Initialize(control, "Region1"),
                        "ContentControl's Content property is not empty.");
                });
        }
开发者ID:xperiandri,项目名称:PortablePrism,代码行数:19,代码来源:ContentControlRegionAdapterFixture.cs

示例4: ContentChanged

 private static void ContentChanged(ContentControl control, IPropertyChangedArgs<string> args)
 {
     control.SetBinding(ContentControl.ContentProperty, args.NewValue);
 }
开发者ID:jamesqo,项目名称:Sirloin,代码行数:4,代码来源:BindingPaths.cs

示例5: CreateControl

 private Control CreateControl(object content)
 {
     var control = new ContentControl
     {
         Content = content,
         RenderTransformOrigin = new Point(0.5, 0.5)
     };
     control.SetBinding(ContentControl.ContentTemplateProperty, new Binding { Source = this, Path = new PropertyPath("ItemTemplate") });
     return control;
 }
开发者ID:ridomin,项目名称:waslibs,代码行数:10,代码来源:SlideShow.Play.cs

示例6: CreateGroupHeader

 private ContentControl CreateGroupHeader(IGroupHeader group)
 {
     ContentControl groupheader = new ContentControl();
     Binding binding = new Binding();
     binding.Source = this;
     binding.Mode = BindingMode.OneWay;
     binding.Path = new PropertyPath("GroupHeaderTemplate");
     groupheader.SetBinding(ContentControl.ContentTemplateProperty, binding);
     groupheader.DataContext = group;
     groupheader.HorizontalAlignment = HorizontalAlignment.Stretch;
     groupheader.HorizontalContentAlignment = HorizontalAlignment.Stretch;
     groupheader.VerticalAlignment = VerticalAlignment.Top;
     groupheader.VerticalContentAlignment = VerticalAlignment.Stretch;
     return groupheader;
 }
开发者ID:GJian,项目名称:UWP-master,代码行数:15,代码来源:GroupListView.cs


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