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

mmap and memcpy usage and Segmentation Fault (core dumped) error

c segmentation-fault mmap memcpy coredump

I have two files and I want to copy one file content to other using memcpy. But I get this error Segmentation Fault (core dumped). My main

Scroll to top script not working in conjunction with overflow:scroll

javascript css3

I wrote this scroll to top script. Everything works great but not with overflow:scroll which I have applied to my wrapper div. The reason I need overflow:scroll is because I have overflow:hidden for