Is there a way to bind "hidden / vivsible" for a window in a simple way.
I currently use a competitors product and the it is pretty easy just like <....IsHidden="{Binding IsChecked}"...
This enables a straight forward way to have a list of ToggleButtons which are use to show / hide windows.
I found syncfusion:DockingManager.State and tried this here (using a converter bool to Float / Hidden) but restoring places the floating (on different monitor) window right above the parent window (changing the size also).
Further problem with this approach - while (with the competitor) setting IsHidden true / false maintains the state (docked, pinned, floating, document...) here I have to remember this somehow.
I found no solution to achieve this without code behind (including to save the state before close to enable a proper "reopen").
By the way "checkbox / ToggleButtons" are just one way - also (like in VS View menu) checked menu items are a typically used for this.
So I tend to say it's very common to show / hide a window.
By the way - with your competitors product this binding works two way - so if the user closes the window with the close button (little x) my ToggleButton get's unchecked.
XAML:
<syncfusion:DockingManager Grid.Row="1" x:Name="dManager" UseDocumentContainer="True" DockStateChanged="dManager_DockStateChanged">
<ContentControl x:Name="SolutionExplorer" syncfusion:DockingManager.Header="Solution Explorer" />
<ContentControl x:Name="Properties" syncfusion:DockingManager.Header="Properties" syncfusion:DockingManager.ShowInTaskbar="False">
<Grid Background="Orange" Height="100" Width="120">
</Grid>
</ContentControl>
<ContentControl x:Name="ToolBox" syncfusion:DockingManager.Header="Toolbox" local:DockChildAdapter.IsHidden="{Binding Path=IsChecked, ElementName=checkBox, Mode=TwoWay, Converter={StaticResource valueconverter}}" syncfusion:DockingManager.State="Float" syncfusion:DockingManager.FloatingWindowRect="100 100 100 100"/>
<ContentControl x:Name="Output" syncfusion:DockingManager.Header="Output"/>
<ContentControl x:Name="StartPage" syncfusion:DockingManager.Header="Start Page" syncfusion:DockingManager.State="Document" />
</syncfusion:DockingManager>
C#:
public class DockChildAdapter
{
public static bool GetIsHidden(DependencyObject obj)
{
return (bool)obj.GetValue(IsHiddenProperty);
}
public static void SetIsHidden(DependencyObject obj, bool value)
{
obj.SetValue(IsHiddenProperty, value);
}
// Using a DependencyProperty as the backing store for IsSpecialTab. This enables animation, styling, binding, etc...
public static readonly DependencyProperty IsHiddenProperty =
DependencyProperty.RegisterAttached("IsHidden", typeof(bool), typeof(DockChildAdapter), new PropertyMetadata(true, null, ExampleCoerceValueCallBack));
private static object ExampleCoerceValueCallBack(DependencyObject d, object value)
{
if((bool)value)
{
DockingManager.SetState(d as DependencyObject, DockState.Float);
}
else
{
DockingManager.SetState(d as DependencyObject, DockState.Hidden);
}
}
} |