Hi,
I understand that LayoutDocumentPane.IsVisible is ReadOnly and you want to bind a property on it to set it to true or false, depending on the current mode.
Please try this complete sample and tell me if it answer your needs.
I understand that LayoutDocumentPane.IsVisible is ReadOnly and you want to bind a property on it to set it to true or false, depending on the current mode.
Please try this complete sample and tell me if it answer your needs.
<Window x:Class="WpfApplication5.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
xmlns:local="clr-namespace:WpfApplication5"
xmlns:s="clr-namespace:System;assembly=mscorlib"
Title="MainWindow">
<Window.Resources>
<FrameworkElement x:Key="ProxyElement" DataContext="{Binding}"/>
</Window.Resources>
<StackPanel>
<ContentControl Visibility="Collapsed"
Content="{StaticResource ProxyElement}"/>
<Button Content="Change CurrentMode" Click="Button_Click_1"/>
<xcad:DockingManager Grid.Row="2" MaxHeight="395"
AllowMixedOrientation="True"
BorderBrush="Black"
BorderThickness="1"
x:Name="_dockingManager">
<xcad:DockingManager.DocumentHeaderTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding IconSource}" Margin="0,0,4,0"/>
<TextBlock Text="{Binding Title}" />
</StackPanel>
</DataTemplate>
</xcad:DockingManager.DocumentHeaderTemplate>
<xcad:LayoutRoot x:Name="_layoutRoot">
<xcad:LayoutPanel Orientation="Horizontal">
<xcad:LayoutAnchorablePane DockWidth="200">
<xcad:LayoutAnchorable ContentId="properties" Title="Properties" CanHide="False" CanClose="False"
AutoHideWidth="240">
<xctk:PropertyGrid NameColumnWidth="110" SelectedObject="{Binding ElementName=_layoutRoot, Path=LastFocusedDocument.Content}" AutoGenerateProperties="False">
<xctk:PropertyGrid.PropertyDefinitions>
<xctk:PropertyDefinition TargetProperties="Background" />
<xctk:PropertyDefinition TargetProperties="BorderBrush" />
<xctk:PropertyDefinition TargetProperties="BorderThickness" />
<xctk:PropertyDefinition TargetProperties="FontSize" />
<xctk:PropertyDefinition TargetProperties="FontStyle" />
<xctk:PropertyDefinition TargetProperties="Width" />
<xctk:PropertyDefinition TargetProperties="Height" />
</xctk:PropertyGrid.PropertyDefinitions>
</xctk:PropertyGrid>
</xcad:LayoutAnchorable>
</xcad:LayoutAnchorablePane>
<xcad:LayoutDocumentPaneGroup >
<local:MyLayoutDocumentPane MyBool="{Binding DataContext.CurrentMode, Source={StaticResource ProxyElement}}">
<xcad:LayoutDocument ContentId="document1" Title="Document 1" >
<Button Content="Document 1 Content" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</xcad:LayoutDocument>
<xcad:LayoutDocument ContentId="document2" Title="Document 2">
<TextBox Text="Document 2 Content" AcceptsReturn="True"/>
</xcad:LayoutDocument>
</local:MyLayoutDocumentPane>
</xcad:LayoutDocumentPaneGroup >
<xcad:LayoutAnchorablePaneGroup DockWidth="125">
<xcad:LayoutAnchorablePane>
<xcad:LayoutAnchorable ContentId="alarms" Title="Alarms" >
<ListBox>
<s:String>Alarm 1</s:String>
<s:String>Alarm 2</s:String>
<s:String>Alarm 3</s:String>
</ListBox>
</xcad:LayoutAnchorable>
<xcad:LayoutAnchorable ContentId="journal" Title="Journal" >
<RichTextBox>
<FlowDocument>
<Paragraph FontSize="14" FontFamily="Segoe">
This is the content of the Journal Pane.
<LineBreak/>
A
<Bold>RichTextBox</Bold> has been added here
</Paragraph>
</FlowDocument>
</RichTextBox>
</xcad:LayoutAnchorable>
</xcad:LayoutAnchorablePane>
</xcad:LayoutAnchorablePaneGroup>
</xcad:LayoutPanel>
<xcad:LayoutRoot.LeftSide>
<xcad:LayoutAnchorSide>
<xcad:LayoutAnchorGroup>
<xcad:LayoutAnchorable Title="Agenda" ContentId="agenda" >
<TextBlock Text="Agenda Content" Margin="10" FontSize="18" FontWeight="Black" TextWrapping="Wrap"/>
</xcad:LayoutAnchorable>
<xcad:LayoutAnchorable Title="Contacts" ContentId="contacts" >
<TextBlock Text="Contacts Content" Margin="10" FontSize="18" FontWeight="Black" TextWrapping="Wrap"/>
</xcad:LayoutAnchorable>
</xcad:LayoutAnchorGroup>
</xcad:LayoutAnchorSide>
</xcad:LayoutRoot.LeftSide>
</xcad:LayoutRoot>
</xcad:DockingManager>
</StackPanel>
</Window>
namespace WpfApplication5
{
public partial class MainWindow : Window
{
public MainWindow()
{
Xceed.Wpf.Toolkit.Licenser.LicenseKey = "XXXXX-XXXXX-XXXXX-XXXX";
InitializeComponent();
this.DataContext = this;
this.CurrentMode = false;
}
#region CurrentMode
public static readonly DependencyProperty CurrentModeProperty = DependencyProperty.Register( "CurrentMode", typeof( bool ), typeof( MainWindow ),
new UIPropertyMetadata( true ) );
public bool CurrentMode
{
get
{
return (bool)GetValue( MainWindow.CurrentModeProperty );
}
set
{
SetValue( MainWindow.CurrentModeProperty, value );
}
}
#endregion //CurrentMode
private void Button_Click_1( object sender, RoutedEventArgs e )
{
this.CurrentMode = !this.CurrentMode;
}
}
public class MyLayoutDocumentPane : LayoutDocumentPane
{
#region MyBool
public static readonly DependencyProperty MyBoolProperty = DependencyProperty.Register( "MyBool", typeof( bool ), typeof( MyLayoutDocumentPane ),
new UIPropertyMetadata( true, OnMyBoolChanged ) );
public bool MyBool
{
get
{
return (bool)GetValue( MyLayoutDocumentPane.MyBoolProperty );
}
set
{
SetValue( MyLayoutDocumentPane.MyBoolProperty, value );
}
}
private static void OnMyBoolChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
{
((MyLayoutDocumentPane)d).OnMyBoolChanged( (bool)e.OldValue, (bool)e.NewValue );
}
protected virtual void OnMyBoolChanged( bool oldValue, bool newValue )
{
this.ComputeVisibility();
}
#endregion //MyBool
protected override bool GetVisibility()
{
return this.MyBool;
}
}
}