Hi,
Please look the code below.
I want to set the visibility of the close button when visibility of edit button gets changed. Line which is bold does not seems to have working.
Please suggest, also if u can let me know how to deactivate the menu on right click of pane.
<
="Eclipsys.SunriseXA.SIRI.Client.HomeScreen.WidgetPane"
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
="http://infragistics.com/DockManager"
="http://schemas.microsoft.com/winfx/2006/xaml"
="clr-namespace:Eclipsys.SunriseXA.PE.WPFUIControls;assembly=Eclipsys.SunriseXA.PE.WPFUIControls">
>
.CloseButtonStyleKey}">
="ContentTemplate">
="pack://application:,,,/Eclipsys.SunriseXA.SIRI.Client.HomeScreen;component/Images/delete.png"
="closeImage">
="Transparent" />
.PinButtonStyleKey}">
="Collapsed"/>
.PositionMenuItemStyleKey}">
="Right">
="Transparent">
="pack://application:,,,/Eclipsys.SunriseXA.SIRI.Client.HomeScreen;component/Images/edit.png"
="_16x16"/>
</
-Toral.
With regards to the right click menu, the context menu is shown by the PaneHeaderPresenter and PaneTabItem when there is no context menu set for those elements. So you could either provide a style for those elements that sets the context menu to something (or x:Null) or you could handle the ContentPane's OptionsMenuOpening and clear the e.Items collection for that event. If there are no menu items then the menu will not be shown. Note, this event is also used for the PaneToolWindow when right clicking on the caption of the window and for the window position menu but from the snippet you're hiding that anyway.
Should this be as simple as adding
<Setter Property="ContextMenu" Value="{x:Null}"/>
to the PaneHeaderPresenter style?
I've tried this, but to no avail.
We have our own template for the PaneHeaderPresenter style, and I've also tried adding ContextMenu="{x:Null}" to nearly every element in the tree, and the menu still shows up.
Is there some other trick to this?
[Edited to add:] Incidentally, this is within a DocumentContentHost, so there might be more behind-the-scenes menu setup and tweaking going on than I'm aware of...
The ContextMenu would have to be set to null via a local value so you would need to set it null in a custom template for the ContentPane where the PaneHeaderPresenter is allocated for the ContentPane. If that doesnt' work then please post a sample and I will look into why it's still showing up.
Here's a sample. Look where I have BlankContextMenu - which is a hacked approach where I create essentially an invisible menu. If I point to that from PaneHeaderPresenter style, there's no menu (although there's the side effect that it really is still there, so that a second click is often - but not always - needed to make the menu go away, even though it's invisible). If I instead change the reference from BlankContextMenu to {x:Null}, the original Infragistics menu appears.
<Window x:Class="XamDockManager.Window9" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:igDock="http://infragistics.com/DockManager"> <igDock:XamDockManager> <igDock:DocumentContentHost> <igDock:SplitPane> <igDock:SplitPane.Resources> <ContextMenu x:Key="BlankContextMenu" HasDropShadow="False" Background="{x:Null}" Foreground="{x:Null}" BorderBrush="{x:Null}"/> <Style TargetType="{x:Type igDock:PaneHeaderPresenter}"> <Setter Property="TextBlock.TextTrimming" Value="CharacterEllipsis" /> <Setter Property="Padding" Value="4,0,4,0"/> <Setter Property="Height" Value="18"/> <Setter Property="BorderThickness" Value="0,0,0,1"/> <Setter Property="BorderBrush" Value="Black"/> <Setter Property="ContextMenu" Value="{StaticResource BlankContextMenu}"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDock:PaneHeaderPresenter}"> <Grid VerticalAlignment="Top" Height="{TemplateBinding Height}"> <Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" VerticalAlignment="Stretch"> <DockPanel Margin="{TemplateBinding Padding}" VerticalAlignment="Center"> <Border DockPanel.Dock="Right"> <Grid> <Button x:Name="closeBtn" DockPanel.Dock="Right" Command="{x:Static igDock:ContentPaneCommands.Close}" CommandParameter="{TemplateBinding Pane}" Style="{DynamicResource {x:Static igDock:PaneHeaderPresenter.CloseButtonStyleKey}}"/> </Grid> </Border> <Border DockPanel.Dock="Left"> <Grid> <ContentPresenter Margin="{TemplateBinding Padding}" VerticalAlignment="Center"/> </Grid> </Border> </DockPanel> </Border> </Grid> </ControlTemplate> </Setter.Value> </Setter> <Setter Property="Background" Value="{x:Null}"/> </Style> <Style TargetType="{x:Type igDock:ContentPane}"> <Setter Property="BorderBrush" Value="{DynamicResource {x:Static igDock:DockManagerBrushKeys.ContentPaneBorderFillKey}}" /> <Setter Property="BorderThickness" Value="1,1,1,1"/> <Setter Property="SnapsToDevicePixels" Value="True"/> <Setter Property="TabHeader" Value="{Binding Path=Header, RelativeSource={x:Static RelativeSource.Self}}" /> <Setter Property="FocusVisualStyle" Value="{x:Null}" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDock:ContentPane}"> <AdornerDecorator> <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"> <DockPanel Margin="{TemplateBinding Padding}"> <igDock:PaneHeaderPresenter DockPanel.Dock="Top" Background="LightBlue" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" DataContext="{Binding RelativeSource={x:Static RelativeSource.TemplatedParent}}" Visibility="Visible" /> <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Visibility="{TemplateBinding ContentVisibility}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"/> </DockPanel> </Border> </AdornerDecorator> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style TargetType="{x:Type igDock:TabGroupPane}"> <Setter Property="Control.Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDock:TabGroupPane}"> <Grid> <ItemsPresenter Visibility="Hidden" MaxHeight="1" MaxWidth="1" /> <ContentPresenter ContentSource="SelectedContent" Margin="{TemplateBinding Padding}" x:Name="PART_SelectedContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentTemplateSelector="{TemplateBinding SelectedContentTemplateSelector}" ContentTemplate="{TemplateBinding SelectedContentTemplate}" Content="{TemplateBinding SelectedContent}" /> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </igDock:SplitPane.Resources> <igDock:TabGroupPane > <igDock:ContentPane Header="Pane1"/> </igDock:TabGroupPane> <igDock:TabGroupPane > <igDock:ContentPane Header="Pane2"/> </igDock:TabGroupPane> </igDock:SplitPane> </igDock:DocumentContentHost> </igDock:XamDockManager></Window>
Yes I see the issue now. In theory setting it to x:Null on the PaneHeaderPresenter itself within the ContentPane template should have worked but it looks like this is considered a ParentTemplate value and not a local value. I'll see about getting this issue submitted. For now the only way to do this would be to handle the OptionsMenuOpening event of the ContentPane and clear the Items of the event args - however this would prevent the menu for things like the Window Position menu in the PaneHeaderPresenter as well.