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
1425
Showing ContentPane when its closed
posted

Hi,

I have a content page which I want to show based on a value being not null and I am using a converter for that.

Here is the code:

<igDock:SplitPane igDock:SplitPane.RelativeSize="100,100" SplitterOrientation="Vertical" >
                        <igDock:ContentPane TabHeader="ViewerContentPane"
                                        x:Name="MyPane"
                                        >
                            <igDock:ContentPane.Header>
                                <TextBlock>
                                <Run Text="Second Grid"/>
                                </TextBlock>
                            </igDock:ContentPane.Header>
                            <igDP:XamDataGrid BindToSampleData="True" FieldLayoutInitialized="XamDataGrid_FieldLayoutInitialized"/>
                        </igDock:ContentPane>
                        <igDock:ContentPane TabHeader="Viewer" AllowClose="True"
                                        x:Name="ViewerPane" MinWidth="200" AutomationProperties.AutomationId="MyViewerPane"
                                        Header="Viewer" >
                            <igDock:ContentPane.Style>
                                <Style>
                                    <Setter Property="igDock:ContentPane.Visibility" Value="Collapsed"/>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Path=Tag, ElementName=MyViewer, Converter={StaticResource isNullConverter}}" Value="False">
                                            <Setter Property="igDock:ContentPane.Visibility" Value="Visible"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </igDock:ContentPane.Style>
                            <ContentControl x:Name="MyViewer"></ContentControl>
                        </igDock:ContentPane>
                    </igDock:SplitPane>

here is the converter:

public class IsNullConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return (value == null);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new InvalidOperationException("IsNullConverter can only be used OneWay.");
        }
    }

 

Will appreciate your help.

Thanks,

Imad.

Parents
No Data
Reply
  • 54937
    Offline posted

    I'm not sure that will work since you're doing a OneWay binding but assuming it would have worked clicking the Close button will set the Visibility to Collapsed which will have a higher dependency property precedence than the Style Setter. For CLR4 we might be able to switch our code so that we use SetCurrentValue but for CLR 3 there is no way around that. If you're using CLR 4 then you might be able to handle the Closing event, set e.Cancel to true and use SetCurrentValue (e.g. "((ContentPane)e.OriginalSource).SetCurrentValue(UIElement.VisibilityProperty, Visibility.Collapsed);" ).

Children