當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。