10/02/2012

Create the Property Inspector In WPF

From last post we will create the Property Inspector window and include it in the WPF grid. To do this, in Solution Explorer right-click the MainWindow.xaml files, choose View Code. Modify the code by following these steps:

  1. Place the PropertyInspector window to the rightmost column of the WPF grid. To do this, add a private method AddPropertyInspector to the MainWindow class.
    C#
    private void AddPropertyInspector()
    {
        Grid.SetColumn(wd.PropertyInspectorView, 2);
        grid1.Children.Add(wd.PropertyInspectorView);
    }
    Visual Basic
    Private Sub AddPropertyInspector()
        Grid.SetColumn(wd.PropertyInspectorView, 2)
        grid1.Children.Add(wd.PropertyInspectorView)
    End Sub
    1. End Sub
  2. Add a call to the AddPropertyInspector method created in the previous step. To do this, add the following code (shown in bold) to MainWindow class constructor.
    C#
    public MainWindow()
    {
        InitializeComponent();
        this.RegisterMetadata();
        this.AddDesigner();
        this.AddToolBox();

        this.AddPropertyInspector();
    }
    Visual Basic
    Public Sub New()
        InitializeComponent()
        Me.RegisterMetadata()
        Me.AddDesigner()
        Me.AddToolBox()

        Me.AddPropertyInspector()
    End Sub
  3. Press CTRL+S to save the changes
  4. Press CTRL+F5 to build and run the solution and verify that the PropertyInspector window is created in the rightmost column of the grid.
    The WPF application hosting the WorkflowDesigner, the Toolbox and the PropertyInspector
    The WPF application hosting the WorkflowDesigner, the Toolbox and the PropertyInspector






No comments:

Post a Comment