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
115
Disable the menu on right click of Pane and set the visibility of close button
posted

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.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

<

 

 

igDock:ContentPane x:Class

="Eclipsys.SunriseXA.SIRI.Client.HomeScreen.WidgetPane"

 

 

xmlns

="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

 

 

xmlns:igDock

="http://infragistics.com/DockManager"

 

 

xmlns:x

="http://schemas.microsoft.com/winfx/2006/xaml"

 

 

xmlns:Eclipsys_SunriseXA_PE_WPFUIControls

="clr-namespace:Eclipsys.SunriseXA.PE.WPFUIControls;assembly=Eclipsys.SunriseXA.PE.WPFUIControls">

 

 

 

<igDock:ContentPane.Resources

>

 

 

 

<Style TargetType="{x:Type Button}" x:Key="{x:Static igDock:PaneHeaderPresenter

.CloseButtonStyleKey}">

 

 

 

<Setter Property

="ContentTemplate">

 

 

 

<Setter.Value

>

 

 

 

<DataTemplate

>

 

 

 

<Eclipsys_SunriseXA_PE_WPFUIControls:EclpImage

 

 

ImagePath

="pack://application:,,,/Eclipsys.SunriseXA.SIRI.Client.HomeScreen;component/Images/delete.png"

 

 

ImageSize="_16x16" x:Name

="closeImage">

 

 

 

</Eclipsys_SunriseXA_PE_WPFUIControls:EclpImage

>

 

 

 

</DataTemplate

>

 

 

 

</Setter.Value

>

 

 

 

</Setter

>

 

 

 

<Setter Property="Background" Value

="Transparent" />

 

 

 

<Setter Property="BorderBrush" Value

="Transparent" />

 

 

 

<Setter Property="Visibility" Value="{Binding ElementName=editButton , Path=Visibility}"></Setter

>

 

 

 

</Style

>

 

 

 

<Style TargetType="{x:Type Button}" x:Key="{x:Static igDock:PaneHeaderPresenter

.PinButtonStyleKey}">

 

 

 

<Setter Property="Visibility" Value

="Collapsed"/>

 

 

 

</Style

>

 

 

 

<Style TargetType="{x:Type MenuItem}" x:Key="{x:Static igDock:PaneHeaderPresenter

.PositionMenuItemStyleKey}">

 

 

 

<Setter Property="Visibility" Value

="Collapsed"/>

 

 

 

</Style

>

 

 

 

</igDock:ContentPane.Resources

>

 

 

 

<igDock:ContentPane.HeaderTemplate

>

 

 

 

<DataTemplate

>

 

 

 

<StackPanel Orientation="Horizontal" HorizontalAlignment

="Right">

 

 

 

<Button x:Name="editButton" Click="editButton_Click" Background="Transparent" BorderBrush

="Transparent">

 

 

 

<Button.Content

>

 

 

 

<Eclipsys_SunriseXA_PE_WPFUIControls:EclpImage

 

 

ImagePath

="pack://application:,,,/Eclipsys.SunriseXA.SIRI.Client.HomeScreen;component/Images/edit.png"

 

 

ImageSize

="_16x16"/>

 

 

 

</Button.Content

>

 

 

 

</Button

>

 

 

 

</StackPanel

>

 

 

 

</DataTemplate

>

 

 

 

</igDock:ContentPane.HeaderTemplate

>

</

 

 

igDock:ContentPane

>

-Toral.

  • 54937
    Offline posted

    You can't use an ElementName binding in a style setter and certainly not to something in a different namescope - specifically the editButton name only exists within the datatemplate you're using for the headertemplate. What I would do is to create an attached property - e.g. CloseButtonVisibility. Set that property on the element that is the content (i.e. allow the content to determine when the close button should be visible based on some internal state). On the ContentPane bind the value of that property for the contentpane to the property on the content. Then in the Setter for the Visibility, set it to a binding to the CloseButtonVisibility of the ancestor ContentPane. Something like:

    <igDock:ContentPane 
        Header="Test" 
        local:Window24.CloseButtonVisibility="{Binding 
            Path=(local:Window24.CloseButtonVisibility), 
            ElementName=cboContent}">
        <igDock:ContentPane.Resources>
            <Style TargetType="{x:Type Button}" 
                   x:Key="{x:Static igDock:PaneHeaderPresenter.CloseButtonStyleKey}">
                <Setter 
                    Property="Visibility" 
                    Value="{Binding Path=(local:Window24.CloseButtonVisibility), 
                        RelativeSource={RelativeSource 
                            AncestorType={x:Type igDock:ContentPane}}}"/>
            </Style>
            <Style TargetType="{x:Type Button}" 
                   x:Key="{x:Static igDock:PaneHeaderPresenter.PinButtonStyleKey}">
                <Setter Property="Visibility" Value="Collapsed"/>
            </Style>
            <Style TargetType="{x:Type MenuItem}" 
                   x:Key="{x:Static igDock:PaneHeaderPresenter.PositionMenuItemStyleKey}">
                <Setter Property="Visibility" Value="Collapsed"/>
            </Style>
        </igDock:ContentPane.Resources>
        <ComboBox x:Name="cboContent" local:Window24.CloseButtonVisibility="Visible" />
    </igDock:ContentPane>