Reputation: 159
I'm using the WPF Multiple Document Interface from this site http://wpfmdi.codeplex.com/. How can I maximize the box inside the code the same way it is done when I click maximize button?
<DockPanel>
<mdi:MdiContainer Theme="Luna" DockPanel.Dock="Top" Margin="0 20 0 0" Name="MainMdiContainer">
<mdi:MdiChild Name="TestWindow" Title="Child Window" Background="AliceBlue" Resizable="True" />
</mdi:MdiContainer>
</DockPanel>
I've tried something like
TestWindow.WindowState = System.Windows.WindowState.Maximized;
but when I do so I cannot see the buttons I normally see when I press the Maximize button.
Upvotes: 1
Views: 1360
Reputation: 3306
Your code works. Your problem must be somewhere else.
XAML :
<mdi:MdiContainer Grid.Column="2" x:Name="Container" Background="#bdbdbd" AllowDrop="True">
<mdi:MdiChild Name="TestWindow" Title="Child Window" Background="AliceBlue" Resizable="True" />
</mdi:MdiContainer>
C# :
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
TestWindow.MouseDown += TestResize;
}
private void TestResize(object sender, MouseButtonEventArgs e)
{
var mdiChild = sender as MdiChild;
if (mdiChild != null)
{
mdiChild.WindowState = WindowState.Maximized;
}
}
}
Note : I use a modified version of WPF MDI because there is a bug in the mode maximized for the current version. The content height is bigger than the MdiChild content height. I posted on codeplex a solution : http://wpfmdi.codeplex.com/discussions/543694
Upvotes: 2