Articles in this section
Category / Section

How to restrict maximizing of newly created MDI window when already another MDI Window in Maximized state in DocumentContainer?

1 min read

By default, we cannot open the MDIWindow of DocumentContainer in Normal state, even if one of the MDIWindow is in MaximizedState.To restrict the maximizing behavior of newly created MDI window when already there is a maximized MDI window, the state of MDI window need to restore Normal state.

XAML:

<Window x:Class="DocumentContainer_MDIwindow.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button x:Name="Button1" Width="100" Height="23" Click="Button1_Click" Content="Newcontent" Grid.Row="0"/>
<syncfusion:DocumentContainer x:Name="Container"  Mode="MDI" Grid.Row="1" >
<ContentControl syncfusion:DocumentContainer.Header="Document1"/>
</syncfusion:DocumentContainer>
</Grid>
</Window>

 

C#:

namespace DocumentContainer_MDIwindow
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            Container.Items.CollectionChanged+=Items_CollectionChanged;       
        }
 
        void Items_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
            {
                foreach (var child in (sender as DocumentCollection))
                {
// Restore the MDI window to Normal state.
                    DocumentContainer.SetMDIWindowState(child as DependencyObject, MDIWindowState.Normal);
                }
            }
        }
 
        private void Button1_Click(object sender, RoutedEventArgs e)
        {
            ContentControl content = new ContentControl();
            DocumentContainer.SetHeader(content, "Document2");
            Container.Items.Add(content);
        }   
    }
}
 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied