コード例 #1
0
ファイル: GroupListView1.cs プロジェクト: GJian/UWP-master
        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));
            }
        }
コード例 #2
0
ファイル: TreeView.cs プロジェクト: karpinsn/AntStrength
        /// <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);
            }
        }
コード例 #3
0
        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.");
                });
        }
コード例 #4
0
ファイル: BindingPaths.cs プロジェクト: jamesqo/Sirloin
 private static void ContentChanged(ContentControl control, IPropertyChangedArgs<string> args)
 {
     control.SetBinding(ContentControl.ContentProperty, args.NewValue);
 }
コード例 #5
0
ファイル: SlideShow.Play.cs プロジェクト: ridomin/waslibs
 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;
 }
コード例 #6
0
ファイル: GroupListView.cs プロジェクト: GJian/UWP-master
 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;
 }