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


C# DockPanel.SetBinding方法代码示例

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


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

示例1: CreatePanels

        void CreatePanels()
        {
            int nbPanels = _panel.MaxColumnByRowProperty * _panel.MaxRowProperty;

            int column = 0;
            int row = 0;
            bool rightDirection = true;
            for( int i = 0; i < nbPanels; i++ )
            {
                DockPanel dp = new DockPanel();
                dp.DataContext = _panel.Panels[i];
                dp.SetBinding( DockPanel.BackgroundProperty, new Binding( "IsActive" ) { Converter = new BooleanToColor() } );

                Grid.SetColumn( dp, column );
                Grid.SetRow( dp, row );
                SplitGrid.Children.Add( dp );

                if( rightDirection ) column++;
                else column--;

                if( column >= _panel.MaxColumnByRowProperty && rightDirection )
                {
                    row++;
                    column--;
                    rightDirection = false;
                }
                else if( column == -1 && !rightDirection )
                {
                    row++;
                    rightDirection = true;
                    column++;
                }
                _dockPanels.Add( dp );
            }
        }
开发者ID:jmathon,项目名称:WPF-Split-Screen,代码行数:35,代码来源:GridZone.xaml.cs

示例2: CreatePropertyPanel

        /// <summary>
        /// Creates the property panel.
        /// </summary>
        /// <param name="pi">
        /// The pi.
        /// </param>
        /// <param name="instance">
        /// The instance.
        /// </param>
        /// <param name="maxLabelWidth">
        /// Width of the max label.
        /// </param>
        /// <returns>
        /// The property panel.
        /// </returns>
        private UIElement CreatePropertyPanel(PropertyItem pi, object instance, ref double maxLabelWidth)
        {
            var propertyPanel = new DockPanel { Margin = new Thickness(2) };
            var propertyLabel = this.CreateLabel(pi);
            var propertyControl = this.CreatePropertyControl(pi);
            if (propertyControl != null)
            {
                if (!double.IsNaN(pi.Width))
                {
                    propertyControl.Width = pi.Width;
                    propertyControl.HorizontalAlignment = HorizontalAlignment.Left;
                }

                if (!double.IsNaN(pi.Height))
                {
                    propertyControl.Height = pi.Height;
                }

                if (!double.IsNaN(pi.MinimumHeight))
                {
                    propertyControl.MinHeight = pi.MinimumHeight;
                }

                if (!double.IsNaN(pi.MaximumHeight))
                {
                    propertyControl.MaxHeight = pi.MaximumHeight;
                }

                if (pi.IsOptional)
                {
                    if (pi.OptionalDescriptor != null)
                    {
                        propertyControl.SetBinding(IsEnabledProperty, new Binding(pi.OptionalDescriptor.Name));
                    }
                    else
                    {
                        propertyControl.SetBinding(
                            IsEnabledProperty, new Binding(pi.Descriptor.Name) { Converter = NullToBoolConverter });
                    }
                }

                if (instance is IDataErrorInfo)
                {
                    if (this.ValidationTemplate != null)
                    {
                        Validation.SetErrorTemplate(propertyControl, this.ValidationTemplate);
                    }

                    if (this.ValidationErrorStyle != null)
                    {
                        propertyControl.Style = this.ValidationErrorStyle;
                    }

                    var errorControl = new ContentControl { ContentTemplate = this.ValidationErrorTemplate };
                    errorControl.SetBinding(
                        VisibilityProperty,
                        new Binding("(Validation.HasError)")
                            {
                                Source = propertyControl,
                                Converter = BoolToVisibilityConverter
                            });
                    errorControl.SetBinding(
                        ContentControl.ContentProperty, new Binding("(Validation.Errors)") { Source = propertyControl });

                    // replace the property control by a stack panel containig the property control and the error control.
                    var sp = new StackPanel();
                    sp.VerticalAlignment = VerticalAlignment.Center;
                    sp.Children.Add(propertyControl);
                    sp.Children.Add(errorControl);
                    propertyControl = sp;
                }
            }

            var actualHeaderPlacement = pi.HeaderPlacement;

            if (!this.ShowCheckBoxHeaders && propertyControl is CheckBox)
            {
                actualHeaderPlacement = HeaderPlacement.Collapsed;
                var cb = propertyControl as CheckBox;
                cb.Content = propertyLabel;

                propertyLabel = null;
            }

            switch (actualHeaderPlacement)
//.........这里部分代码省略.........
开发者ID:betology,项目名称:SambaPOS-3,代码行数:101,代码来源:PropertyControl.cs


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