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.
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);" ).
In fact I have also setting Tag to null in Closed event handler. I forgot to post it.
private void MyViewer_Closed(object sender, Infragistics.Windows.DockManager.Events.PaneClosedEventArgs e) { MyViewer.Tag = null; e.Handled = true; }
The odd behaviour is that initially Contentpane "ViewerPane" gets collapsed due to trigger as Tag value is null. And when I set Tag value ContentPane becomes visible. As long as I set value of Tag and reset it to null, ContentPane is happy to become Visible and Collapsed but as soon as I press close button on ContentPane, its gets Collapsed but never becomes Visible again on setting a value to Tag.
Waiting for your response.