views:

789

answers:

1

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?

+1  A: 

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.

Jobi Joy