WPF: How do I edit the contents of a DockPanel that is located inside a UserControl?

I've created a user control (in vb.net code) that contains two dock panels, one for header content (called HeaderDockPanel) and one for other content (called RootDockPanel). The dockPanels are depedency properties of the user control.

These dependency properties are declared as follows:

Public Shared ReadOnly RootDockPanelProperty As DependencyProperty = DependencyProperty.Register( _
       "RootDockPanel", GetType(DockPanel), GetType(MyUserControl), New PropertyMetadata( _
       Nothing))

Public Shared ReadOnly HeaderDockPanelProperty As DependencyProperty = DependencyProperty.Register( _
            "HeaderDockPanel", GetType(DockPanel), GetType(MyUserControl), New PropertyMetadata( _
            Nothing))

I've tried to change the content of these dock panels as follows but I've had no sucess:

<Wpf:EditBaseControl>
    <Wpf:MyUserControl.HeaderDockPanel>
        <DockPanel>
            <Button Content="buttonContent" />
            <TextBlock Text="textBlock" />
        </DockPanel>
    </Wpf:MyUserControl.HeaderDockPanel>
</Wpf:EditBaseControl>

How do I edit the contents of a DockPanel that's inside a UserControl?

Answers


1 I am not getting your design approach correctly here. Why do you need a Dependancy property as DockPanel. You can directly refer the DockPanel in your usercontrol code behind if you set x:Name property in the XAML and access that name say _dockPanel. Access _dockPanel.Children property to manipuate its chidren,

2 Another thought on the DPs, you might need to add the DockPanel instances to Wpf:EditBaseControl as Content on DependancyPropertyChanged event.

3 If you want to try lookless way (ie, WPF Custom control), then I would suggest you to create a HeaderedItemsControl for this purpose and set ItemsPanel as DockPanel for that control.


Need Your Help

Check is the downloaded mp4 file is proparly downloaded to play. - iphone sdk

ios ios4 video download mp4

I have developed the code for downloading the mp4 video from server. It does work perfectly sometime but sometime the video which is downloaded is not proper so its not playing.

Can we use global.asax file in DotNet class library projects

c# asp.net .net clr

Can we use Global.asax file in .NET Class Library projects? Because I have not seen anywhere that Global.asax file can only be used only with Web based applications.