Пример #1
1
        public Comment(Node hostNode)
        {
            HostNode = hostNode;

            var scrollViewer = new ScrollViewer
            {
                HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
                VerticalScrollBarVisibility = ScrollBarVisibility.Visible,
                Height = 70,
                CanContentScroll = true
            };

            var textBlock = new TextBlock
            {
                Background = Brushes.Transparent,
                TextWrapping = TextWrapping.Wrap,
                Margin = new Thickness(5),
                FontSize = 12
            };

            Child = scrollViewer;
            CornerRadius = new CornerRadius(5);
            scrollViewer.Content = textBlock;


            var bindingTextToTextBlock = new Binding("Text")
            {
                Source = this,
                Mode = BindingMode.OneWay
            };
            textBlock.SetBinding(TextBlock.TextProperty, bindingTextToTextBlock);

            hostNode.SpaceCanvas.Children.Add(this);
        }
        public StockFinancialUserControl()
        {
            InitializeComponent();

            foreach (var prop in (typeof(StockFinancial)).GetProperties())
            {
                if (prop.PropertyType == typeof(DataTable) || prop.PropertyType.Name.StartsWith("List"))
                    continue;
                StackPanel propertyRow = new StackPanel() { Orientation = Orientation.Horizontal };

                // Create financials control
                Label labelTitle = new Label();
                labelTitle.Content = prop.Name;
                labelTitle.Width = 100;

                TextBlock labelValue = new TextBlock();
                labelValue.Margin = new Thickness(0, 5, 0, 0);
                if (prop.Name == "Yield")
                {
                    labelValue.SetBinding(TextBlock.TextProperty, new Binding(prop.Name) { StringFormat = "P2" });
                }
                else
                {
                    labelValue.SetBinding(TextBlock.TextProperty, new Binding(prop.Name));
                }
                propertyRow.Children.Add(labelTitle);
                propertyRow.Children.Add(labelValue);

                this.propertyPanel.Children.Add(propertyRow);
            }
        }
Пример #3
0
        private void AddTextBlocks( )
        {
            _textBlocks = new TextBlock[App.GameModel.Columns, App.GameModel.Rows];
            for(var i = 0; i < App.GameModel.Rows; i++)
            {
                for(var j = 0; j < App.GameModel.Columns; j++)
                {
                    var b = new Border {Style = (Style) Application.Current.Resources["BorderStyle"] };
                    var t = new TextBlock();


                    t.Drop += TextBlock_Drop;
                    t.Style = (Style)Application.Current.Resources["GameBoardTBlockStyle"];
                    b.Child = t;

                    string s = $"App.GameModel.GameBoard[{j},{i}]";
                    var textBinding = new Binding(s);
                    //textBinding.Source = App.GameModel;
                    t.SetBinding(TextBlock.TextProperty, textBinding);

                    var colorBinding = new Binding("AllowDrop")
                    {
                        Source = t,
                        Converter = new BoolToColorConverter()
                    };
                    t.SetBinding(TextBlock.BackgroundProperty, colorBinding);
                    Grid.SetRow(b, i);
                    Grid.SetColumn(b, j);
                    _textBlocks[j, i] = t;
                    GameBoard.Children.Add(b);
                }
            }
        }
        public UIBoundToCustomerWithItemsControl()
        {
            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();
            stack.Children.Add(addressStack);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("MailingAddress.Street")); //misspelling
            addressStack.Children.Add(textBlock);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("MailingAddress.City"));
            addressStack.Children.Add(textBlock);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("BllingAddress.Street2")); //misspelling
            addressStack.Children.Add(textBlock);

            var listBox = new ListBox {ItemTemplate = CreateItemTemplate()};
            listBox.SetBinding(ListBox.ItemsSourceProperty, new Binding("Orders"));
            stack.Children.Add(listBox);
        }
        public UIBoundToCustomerWithNesting()
        {
            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();
            stack.Children.Add(addressStack);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("MailingAddress.Street")); //misspelling
            addressStack.Children.Add(textBlock);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("MailingAddress.City"));
            addressStack.Children.Add(textBlock);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("BllingAddress.Street2")); //misspelling
            addressStack.Children.Add(textBlock);
        }
Пример #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ImageButton"/> class.
        /// </summary>
        public ImageButton()
        {
            SetResourceReference(HeightProperty, "DefaultControlHeight");

            var panel = new StackPanel {Orientation = Orientation.Horizontal};

            _icon = new Image {Margin = new Thickness(0, 0, 6, 0)};
            var imageBinding = new Binding("Icon")
                               	{
                               		Source = this,
                               		UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                               	};
            _icon.SetBinding(Image.SourceProperty, imageBinding);

            panel.Children.Add(_icon);

            _textBlock = new TextBlock();
            var textBinding = new Binding("Content")
                              	{
                              		Source = this,
                              		UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                              	};
            _textBlock.SetBinding(TextBlock.TextProperty, textBinding);
            panel.Children.Add(_textBlock);

            base.Content = panel;

            SetResourceReference(StyleProperty, typeof (Button));
        }
Пример #7
0
        public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)
        {
            TextBlock tb = new TextBlock();
            tb.SetBinding(TextBlock.TextProperty, new Binding(this.DataMemberBinding.Path.Path) { Converter = new MyConverter() });

            return tb;
        }
        void kmllayer_Initialized(object sender, System.EventArgs e)
        {
            foreach (Layer layer in (sender as KmlLayer).ChildLayers)
            {
                layer.Visible = true;

                Border border = new Border()
                {
                    Background = new SolidColorBrush(Colors.White),
                    BorderBrush = new SolidColorBrush(Colors.Black),
                    BorderThickness = new Thickness(1),
                    CornerRadius = new CornerRadius(5)
                };

                StackPanel stackPanelChild = new StackPanel()
                {
                    Orientation = Orientation.Horizontal,
                    Margin = new Thickness(5)
                };

                TextBlock textValue = new TextBlock();
                Binding valueBinding = new Binding(string.Format("[{0}]", "name"));
                textValue.SetBinding(TextBlock.TextProperty, valueBinding);

                stackPanelChild.Children.Add(textValue);

                border.Child = stackPanelChild;
                (layer as KmlLayer).MapTip = border;
            }
        }
        public SimpleUIBoundToCustomer()
        {
            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("LstName")); //purposefully misspelled
            stack.Children.Add(textBlock);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding()); //context
            stack.Children.Add(textBlock);

            var checkbox = new CheckBox();
            checkbox.SetBinding(CheckBox.IsCheckedProperty, new Binding("asdfsdf")); //does not exist
            stack.Children.Add(checkbox);

            var tooltip = new ToolTip();
            tooltip.SetBinding(System.Windows.Controls.ToolTip.ContentProperty, new Binding("asdfasdasdf")); // does not exist
            stack.ToolTip = tooltip;

            var childUserControl = new SimpleUIBoundToCustomerByAttachedPorperty();
            stack.Children.Add(childUserControl);
        }
        public FrameworkElement BuildElement()
        {
            var panel = new StackPanel();
            panel.Orientation = Orientation.Horizontal;
            panel.Margin = new Thickness(2);

            var textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding(bindingPath));
            textBlock.Margin = new Thickness(0,0,2,0);

            var button = new Button();
            var source = new BitmapImage();

            var uri1 = new Uri("pack://application:,,,/Commons.UI.WPF;component/Images/binary.png", UriKind.Absolute);
            source.BeginInit();
            source.UriSource = uri1;
            source.EndInit();

            var image = new Image()
                          	{
                          		Source = source,
                          		Width = 16
                          	};

            button.Content = image;
            button.Click += ShowBinaryViewer;

            panel.Children.Add(textBlock);
            panel.Children.Add(button);
            return panel;
        }
        /// <summary>
        /// Add a new message to the subtopic box
        /// </summary>
        /// <param name="message"></param>
        public void Send(Message message)
        {
            Messages.Add(message);

            // Create the textblock control
            TextBlock visualMessage = new TextBlock();
            visualMessage.TextWrapping = TextWrapping.Wrap;
            visualMessage.Text = message.Text;
            visualMessage.DataContext = Contents;

            // Set width databinding for 
            var widthBinding = new Binding("ActualWidth");
            widthBinding.Source = Content;
            widthBinding.Mode = BindingMode.OneWay;
            visualMessage.SetBinding(TextBlock.MaxWidthProperty, widthBinding);

            if (message.Sender == MessageSender.Ai)
            {
                // AI messages are displayed in bold type
                visualMessage.FontWeight = FontWeights.Bold;
            }
            else
            {
                // User messages are displayed with a prompt character,
                // and in italic type
                visualMessage.Text = " > " + visualMessage.Text;
                visualMessage.FontStyle = FontStyles.Oblique;
            }

            Contents.Children.Add(visualMessage);
        }
Пример #12
0
        /// <summary>
        /// Load Zoom Out text (for zooming) at the top-right corner of PlotArea
        /// </summary>
        private void LoadZoomOutIcon()
        {
            _zoomOutTextBlock = new System.Windows.Controls.TextBlock();
            _zoomOutTextBlock.HorizontalAlignment = HorizontalAlignment.Right;
            _zoomOutTextBlock.VerticalAlignment   = VerticalAlignment.Center;
            _zoomOutTextBlock.Margin = new Thickness(2, 0, 0, 0);
            _zoomOutTextBlock.Cursor = Cursors.Hand;

            Binding binding = new Binding("ZoomOutText");

            binding.Source = this;
            _zoomOutTextBlock.SetBinding(TextBlock.TextProperty, binding);

            //_zoomOutTextBlock.Text = "Zoom Out";

            _zoomOutTextBlock.FontSize = 9;

            _zoomOutTextBlock.MouseMove += delegate(Object sender, MouseEventArgs e)
            {
                _zoomOutTextBlock.TextDecorations = TextDecorations.Underline;
            };

            _zoomOutTextBlock.MouseLeave += delegate(Object sender, MouseEventArgs e)
            {
                _zoomOutTextBlock.TextDecorations = null;
            };

            _zoomOutTextBlock.Visibility = Visibility.Collapsed;
            _zoomIconContainer.Children.Add(_zoomOutTextBlock);
        }
Пример #13
0
		internal static Grid CreateFallbackRoot ()
		{
			Grid grid = new Grid ();
			TextBlock block = new TextBlock ();
			block.SetBinding (TextBlock.TextProperty, new Binding ());
			grid.Children.Add (block);
			return grid;
		}
Пример #14
0
        protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
        {
            TextBlock cellElement = new TextBlock();

            System.Windows.Data.Binding textBinding = new System.Windows.Data.Binding(cell.Column.Header + ".DisplayValue")
                                                          {Source = dataItem};
            cellElement.SetBinding(TextBlock.TextProperty, textBinding);

            System.Windows.Data.Binding backgroundBinding = new System.Windows.Data.Binding(cell.Column.Header + ".Background")
                                                                {Source = dataItem};
            cellElement.SetBinding(TextBlock.BackgroundProperty, backgroundBinding);

            System.Windows.Data.Binding foreGroundBinding = new System.Windows.Data.Binding(cell.Column.Header + ".Foreground")
                                                                {Source = dataItem};
            cellElement.SetBinding(TextBlock.ForegroundProperty, foreGroundBinding);

            return cellElement;
        }
        protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
        {
            var binding = new Binding(bindingPath);

            var textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, binding);
            textBlock.Margin = new Thickness(0, 0, 2, 0);

            return BuildElement(textBlock);
        }
        /// <summary>
        /// Generate content for cell by column binding
        /// </summary>
        /// <returns>TextBlock element</returns>
        internal override FrameworkElement GetGeneratedContent()
        {
            TextBlock result = new TextBlock();

            if (this.Binding != null)
            {
                result.SetBinding(TextBlock.TextProperty, this.Binding);
            }

            return result;
        }
Пример #17
0
        protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
        {
            TextBlock block = new TextBlock
            {
                Margin = new Thickness(4.0),
                VerticalAlignment = VerticalAlignment.Center
            };

            block.SetBinding(TextBlock.TextProperty, this.Binding);
            return block;
        }
 protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
 {
     var txt = new TextBlock {VerticalAlignment = VerticalAlignment.Center};
     if (DateFormat != null)
     {
         var dtc = new DateTimeConverter();
         Binding.Converter = dtc;
         Binding.ConverterParameter = DateFormat;
     }
     txt.SetBinding(TextBlock.TextProperty, Binding);
     return txt;
 }
Пример #19
0
        protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
        {
            var textBox = new TextBlock();
            textBox.SetBinding(TextBlock.TextProperty, new Binding(".")
            {
                Converter = new IndexOfItemsConverter(DataGridOwner.Items)
            });

            ClipboardContentBinding = new Binding(".")
            {
                Converter = new IndexOfItemsConverter(DataGridOwner.Items)
            };
            return textBox;
        }
        public UIWithPrioritybindingToStyle()
        {
            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"));
            textBlock.Style = CreateStyle();

            stack.Children.Add(textBlock);
        }
        public UIBoundToCustomerWithStyleAndMultiTriggers()
        {
            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"));
            textBlock.Style = CreateStyle();

            stack.Children.Add(textBlock);
        }
        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);
        }
        public SimpleUIUsingResourceDictionary()
        {
            var stack = new StackPanel();
            Content = stack;

            var textBlock = new TextBlock();
            textBlock.SetResourceReference(TextBlock.StyleProperty, SimpleResourceDictionary.TextBlockStyleKey);
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("FirstName"));
            stack.Children.Add(textBlock);

            var local = textBlock.GetValue(TextBlock.StyleProperty);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("LstName")); //purposefully misspelled
            stack.Children.Add(textBlock);
        }
Пример #24
0
 /// <summary>
 /// Removes the <c>Microsoft.VisualStudio.Platform.WindowManagement.StringUppercaseConverter</c> Converter
 /// from the binding.
 /// </summary>
 /// <remarks>
 /// Seriously.
 /// </remarks>
 /// <param name="textBlock"></param>
 private static void RemoveOutrageousConverter(TextBlock textBlock)
 {
     BindingExpression bindingExpression = textBlock.GetBindingExpression(TextBlock.TextProperty);
     if (bindingExpression != null)
     {
         Binding binding = bindingExpression.ParentBinding;
         if (binding != null)
         {
             // A binding's converter can't be changed after it has been used.
             // Create a new binding without a converter at all.
             Binding betterBinding = new Binding();
             betterBinding.Path = binding.Path;
             textBlock.SetBinding(TextBlock.TextProperty, betterBinding);
         }
     }
 }
        public UIBoundToCustomerIndexer()
        {
            var stack = new StackPanel();
            Content = stack;

            var textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("FirstName"));
            stack.Children.Add(textBlock);

            var contentControl = new ContentControl();
            contentControl.SetBinding(ContentControl.ContentProperty, new Binding("[0].Quantity"));
            stack.Children.Add(contentControl);

            contentControl = new ContentControl();
            contentControl.SetBinding(ContentControl.ContentProperty, new Binding("[text].Quaity")); //purposefully misspelled
            stack.Children.Add(contentControl);
        }
        public UIBoundToCustomerWithContentControlAndTriggers()
        {
            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 contentControl = new ContentControl {ContentTemplate = CreateItemTemplate()};
            contentControl.SetBinding(ContentControl.ContentProperty, new Binding("MailingAddress"));
            stack.Children.Add(contentControl);
        }
        public SimpleUIWithPriorityBinding()
        {
            var stack = new StackPanel();
            Content = stack;

            var priorityBinding = new PriorityBinding();
            priorityBinding.Bindings.Add(new Binding("FirstName"));
            priorityBinding.Bindings.Add(new Binding("LstName")); //purposefully misspelled

            var textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, priorityBinding);
            stack.Children.Add(textBlock);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("Age"));
            stack.Children.Add(textBlock);
        }
		private IEnumerable<FrameworkElement> CreateDifferentlyLookingLegendItem(IPlotterElement plotterElement)
		{
			StackPanel host = new StackPanel { Orientation = Orientation.Horizontal };

			TextBlock textBlock = new TextBlock();
			textBlock.SetBinding(TextBlock.TextProperty, BindingHelper.CreateAttachedPropertyBinding(NewLegend.DescriptionProperty));
			host.Children.Add(textBlock);

			Line line = new Line { X1 = 0, Y1 = 0, X2 = 20, Y2 = 10, Stretch = Stretch.Fill };
			line.SetBinding(Line.StrokeProperty, new Binding("Stroke"));
			line.SetBinding(Line.StrokeThicknessProperty, new Binding("StrokeThickness"));
			host.Children.Add(line);

			host.DataContext = plotterElement;

			yield return host;
		}
        public SimpleUIBoundToCustomerByAttachedPorperty()
        {
            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(Grid.ZIndexProperty, new Binding("Ag")); //purposefully misspelled
            stack.Children.Add(textBlock);

            textBlock = new TextBlock();
            textBlock.SetBinding(Grid.ColumnSpanProperty, new Binding("IQ")); 
            stack.Children.Add(textBlock);
        }
Пример #30
0
        static void Bind_OneWay()
        {
            // Binding Source (Any object).
            var person = new Person1 { Id = 123, Name = "Taro" };

            // Binding Target (DependencyObject).
            var textBlock = new TextBlock { Text = "Default" };
            Console.WriteLine(textBlock.Text);

            // Binds target to source.
            var binding = new Binding(nameof(person.Name)) { Source = person };
            textBlock.SetBinding(TextBlock.TextProperty, binding);
            Console.WriteLine(textBlock.Text);

            // Changes source value.
            person.Name = "Jiro";
            Console.WriteLine(textBlock.Text);
        }
        protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
        {
            base.GenerateElement(cell, dataItem);
            TextBlock tb = new TextBlock { HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Top };
            tb.Margin = new Thickness(0, 0, 4, 0);

            var b = new Binding();
            b.Path = ((Binding)this.Binding).Path;
            b.Source = dataItem;

            if (b != null)
            {
                b.StringFormat = string.IsNullOrEmpty(StringFormat) ? "N2" : StringFormat;
            }

            tb.SetBinding(TextBlock.TextProperty, b);
            return tb;
        }
        // Token: 0x06004DAF RID: 19887 RVA: 0x0015E684 File Offset: 0x0015C884
        private FrameworkElement CreateCell(GridViewColumn column)
        {
            BindingBase      displayMemberBinding;
            FrameworkElement frameworkElement;

            if ((displayMemberBinding = column.DisplayMemberBinding) != null)
            {
                frameworkElement             = new TextBlock();
                frameworkElement.DataContext = this.Content;
                frameworkElement.SetBinding(TextBlock.TextProperty, displayMemberBinding);
            }
            else
            {
                ContentPresenter contentPresenter = new ContentPresenter();
                contentPresenter.Content = this.Content;
                DataTemplate cellTemplate;
                if ((cellTemplate = column.CellTemplate) != null)
                {
                    contentPresenter.ContentTemplate = cellTemplate;
                }
                DataTemplateSelector cellTemplateSelector;
                if ((cellTemplateSelector = column.CellTemplateSelector) != null)
                {
                    contentPresenter.ContentTemplateSelector = cellTemplateSelector;
                }
                frameworkElement = contentPresenter;
            }
            ContentControl contentControl;

            if ((contentControl = (base.TemplatedParent as ContentControl)) != null)
            {
                frameworkElement.VerticalAlignment   = contentControl.VerticalContentAlignment;
                frameworkElement.HorizontalAlignment = contentControl.HorizontalContentAlignment;
            }
            frameworkElement.Margin = GridViewRowPresenter._defalutCellMargin;
            return(frameworkElement);
        }
        /// <summary>
        /// Gets a read-only <see cref="T:System.Windows.Controls.Data.TextBlock" /> element that is bound to the column's <see cref="P:System.Windows.Controls.Data.DataGridBoundColumn.Binding" /> property value.
        /// </summary>
        /// <param name="cell">The cell that will contain the generated element.</param>
        /// <param name="dataItem">The data item represented by the row that contains the intended cell.</param>
        /// <returns>A new, read-only <see cref="T:System.Windows.Controls.Data.TextBlock" /> element that is bound to the column's <see cref="P:System.Windows.Controls.Data.DataGridBoundColumn.Binding" /> property value.</returns>
        protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
        {
            TextBlock textBlockElement = new TextBlock();

            textBlockElement.Margin            = new Thickness(4);
            textBlockElement.VerticalAlignment = VerticalAlignment.Center;
            if (DependencyProperty.UnsetValue != ReadLocalValue(DataGridTextColumn.FontFamilyProperty))
            {
                textBlockElement.FontFamily = this.FontFamily;
            }
            if (this._fontSize.HasValue)
            {
                textBlockElement.FontSize = this._fontSize.Value;
            }
            if (this._fontStyle.HasValue)
            {
                textBlockElement.FontStyle = this._fontStyle.Value;
            }
            if (this._fontWeight.HasValue)
            {
                textBlockElement.FontWeight = this._fontWeight.Value;
            }
            if (this._foreground != null)
            {
                textBlockElement.Foreground = this._foreground;
            }
            else
            {
                textBlockElement.Foreground = this.OwningGrid.Foreground;
            }
            if (this.Binding != null || !DesignerProperties.IsInDesignTool)
            {
                textBlockElement.SetBinding(TextBlock.TextProperty, this.Binding);
            }
            return(textBlockElement);
        }
        /// <summary>Default constructor, creates the UIElements including a PropertyInspector</summary>
        public WpfPropertyGrid()
        {
            this.ColumnDefinitions.Add(new ColumnDefinition());
            this.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star)
            });
            this.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(0)
            });
            this.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(0)
            });

            this.Designer = new WorkflowDesigner();
            TextBlock title = new TextBlock()
            {
                Visibility   = Windows.Visibility.Visible,
                TextWrapping = TextWrapping.NoWrap,
                TextTrimming = TextTrimming.CharacterEllipsis,
                FontWeight   = FontWeights.Bold,
                FontSize     = 30.0
            };
            TextBlock descrip = new TextBlock()
            {
                Visibility   = Windows.Visibility.Visible,
                TextWrapping = TextWrapping.Wrap,
                TextTrimming = TextTrimming.CharacterEllipsis
            };
            DockPanel dock = new DockPanel()
            {
                Visibility    = Windows.Visibility.Visible,
                LastChildFill = true,
                Margin        = new Thickness(3, 0, 3, 0)
            };

            title.SetValue(DockPanel.DockProperty, Dock.Top);
            dock.Children.Add(title);
            dock.Children.Add(descrip);
            this.HelpText = new Border()
            {
                Visibility      = Windows.Visibility.Visible,
                BorderBrush     = SystemColors.ActiveBorderBrush,
                Background      = SystemColors.ControlBrush,
                BorderThickness = new Thickness(1),
                Child           = dock
            };
            this.Splitter = new GridSplitter()
            {
                Visibility          = Windows.Visibility.Visible,
                ResizeDirection     = GridResizeDirection.Rows,
                Height              = 5,
                HorizontalAlignment = Windows.HorizontalAlignment.Stretch
            };

            var inspector = Designer.PropertyInspectorView;

            inspector.Visibility = Visibility.Visible;
            inspector.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Stretch);

            this.Splitter.SetValue(Grid.RowProperty, 1);
            this.Splitter.SetValue(Grid.ColumnProperty, 0);

            this.HelpText.SetValue(Grid.RowProperty, 2);
            this.HelpText.SetValue(Grid.ColumnProperty, 0);

            Binding binding = new Binding("Parent.Background");

            title.SetBinding(BackgroundProperty, binding);
            descrip.SetBinding(BackgroundProperty, binding);

            this.Children.Add(inspector);
            this.Children.Add(this.Splitter);
            this.Children.Add(this.HelpText);

            Type inspectorType = inspector.GetType();
            var  props         = inspectorType.GetProperties(Reflection.BindingFlags.Public | Reflection.BindingFlags.NonPublic | Reflection.BindingFlags.Instance |
                                                             Reflection.BindingFlags.DeclaredOnly);

            var methods = inspectorType.GetMethods(Reflection.BindingFlags.Public | Reflection.BindingFlags.NonPublic | Reflection.BindingFlags.Instance |
                                                   Reflection.BindingFlags.DeclaredOnly);

            this.RefreshMethod = inspectorType.GetMethod("RefreshPropertyList",
                                                         Reflection.BindingFlags.NonPublic | Reflection.BindingFlags.Instance | Reflection.BindingFlags.DeclaredOnly);
            this.IsInAlphaViewMethod = inspectorType.GetMethod("set_IsInAlphaView",
                                                               Reflection.BindingFlags.Public | Reflection.BindingFlags.Instance | Reflection.BindingFlags.DeclaredOnly);
            this.OnSelectionChangedMethod = inspectorType.GetMethod("OnSelectionChanged",
                                                                    Reflection.BindingFlags.Public | Reflection.BindingFlags.Instance | Reflection.BindingFlags.DeclaredOnly);
            this.SelectionTypeLabel = inspectorType.GetMethod("get_SelectionTypeLabel",
                                                              Reflection.BindingFlags.Public | Reflection.BindingFlags.NonPublic | Reflection.BindingFlags.Instance |
                                                              Reflection.BindingFlags.DeclaredOnly).Invoke(inspector, new object[0]) as TextBlock;
            this.PropertyToolBar = inspectorType.GetMethod("get_PropertyToolBar",
                                                           Reflection.BindingFlags.Public | Reflection.BindingFlags.NonPublic | Reflection.BindingFlags.Instance |
                                                           Reflection.BindingFlags.DeclaredOnly).Invoke(inspector, new object[0]) as Control;
            inspectorType.GetEvent("GotFocus").AddEventHandler(this,
                                                               Delegate.CreateDelegate(typeof(RoutedEventHandler), this, "GotFocusHandler", false));

            this.SelectionTypeLabel.Text = string.Empty;
        }