Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
Custom ContentPane and PaneHeaderPresenter
posted

I am trying to add buttons (or any other content) to the contentpanes of the XamDockManager. In order to do this, I subclassed ContentPane into ContentPaneEx) and PaneHeaderPresenter  into PaneHeaderPresenterEx. To both, I added a ContentPresenter dependency property and called it ButtonContent.

I then created styles for both, taking the styles for ContentPane and PaneHeaderPresenter from DefaultStyles as templates. I changed the TargetType for each style to be that of the subclassed versions.

To the ContentPaneEx style, I replace PaneHeaderPresenter with PaneHEaderPresenterEx and added a binding for the ButtonContent property of the PaneHeaderPresenterEx. To the PaneHeaderPresenterEx style, I added the following contentpresenter:
<ContentPresenter x:Name="PART_ButtonContentPresenter" DockPanel.Dock ="Right"
Visibility="{Binding Path=Pane.ButtonContentVisibility, RelativeSource={RelativeSource TemplatedParent}}"
Content="{Binding ButtonContent, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Views:PaneHeaderPresenterEx}}}"
DataContext="{Binding DataContext, RelativeSource={RelativeSource FindAncestorAncestorType={x:Type Views:PaneHeaderPresenterEx}}}"/>

 

Here is my implementation:
<Views:ContentPaneEx x:Name="collateralPane" Header="Heading" AllowClose="False" AllowInDocumentHost="False" AllowFloatingOnly="False" CloseButtonVisibility="Collapsed" WindowPositionMenuVisibility="Collapsed">
<Views:ContentPaneEx.ButtonContent>
<StackPanel Orientation="Horizontal">
<ToggleButton IsChecked="False" Style="{StaticResource style}" />
<ToggleButton IsChecked="True" Style="{StaticResource style2}" />
<ToggleButton IsChecked="False" Style="{StaticResource style3}" />
</StackPanel>
</Views:ContentPaneEx.ButtonContent>
</Views:ContentPaneEx>

(I left the rest of the xaml out.)

 

 

When I run the app now, docked/pinned panes come up fine, but when I drag these panes off and float them, I get an empty window. In the output, I see the following databinding error:

System.Windows.Data Error: 4 :
Cannot find source for binding with reference
'RelativeSource FindAncestor, AncestorType='Infragistics.Windows.Controls.ToolWindow', AncestorLevel='1''.
BindingExpression:Path=IsActive; DataItem=null; target element is 'Button' (Name='CloseButton');
target property is 'NoTarget' (type 'Object')

 

 What am I doing wrong? How can I fix this?

Thanks in advance!

Parents
  • 45
    Offline posted

    Found the problem. Stupid error on my end.

    In ContentPaneEx and PaneHeaderPresenterEx, I had added: DefaultStyleKeyProperty.OverrideMetadata

    Removing it fixed the problem.

Reply Children
No Data