If you look at the Chrome browser when maximized, it has its tab headers right at the top of the window. Can I do something similar?
By setting the ResizeMode property to CanMinimize only the Minimize button will be visible. The maximize button will be hidden and the resizing will be disabled.
Just set the WindowState to Maximized , and the WindowStyle to None . Also setting the Window as topmost will make sure no other Window shows up over your window.
Pressing ALT + F4 . Pressing the Close button. Pressing ESC when a button has the IsCancel property set to true on a modal window.
Absolutely, but you're going to have to remake those buttons yourself (it's not hard, don't worry).
In your MainWindow.xaml:
<Window ...
Title="" Height="Auto" Width="Auto" Icon="../Resources/MyIcon.ico"
ResizeMode="NoResize" WindowStartupLocation="CenterScreen"
WindowStyle="None" AllowsTransparency="True" Background="Transparent"
...>
<Canvas>
<Button /> <!-- Close -->
<Button /> <!-- Minimize -->
<Button /> <!-- Maximize -->
<TabControl>
...
</TabControl>
</Canvas>
</Window>
Then you just have to place the Buttons and the TabControl as wished on the Canvas, and customize the look and feel.
EDIT: The built in commands for closing/maximizing/minimizing in .NET 4.5 are SystemCommands.CloseWindowCommand
/
SystemCommands.MaximizeWindowCommand
/SystemCommands.MinimizeWindowCommand
So if you're using .NET 4.5, you can do:
<Window ...
Title="" Height="Auto" Width="Auto" Icon="../Resources/MyIcon.ico"
ResizeMode="NoResize" WindowStartupLocation="CenterScreen"
WindowStyle="None" AllowsTransparency="True" Background="Transparent"
...>
<Window.CommandBindings>
<CommandBinding Command="{x:Static SystemCommands.CloseWindowCommand}" CanExecute="CommandBinding_CanExecute_1" Executed="CommandBinding_Executed_1" />
<CommandBinding Command="{x:Static SystemCommands.MaximizeWindowCommand}" CanExecute="CommandBinding_CanExecute_1" Executed="CommandBinding_Executed_2" />
<CommandBinding Command="{x:Static SystemCommands.MinimizeWindowCommand}" CanExecute="CommandBinding_CanExecute_1" Executed="CommandBinding_Executed_3" />
</Window.CommandBindings>
<Canvas>
<Button Command="{x:Static SystemCommands.CloseWindowCommand}" Content="Close" />
<Button Command="{x:Static SystemCommands.MaximizeWindowCommand}" Content="Maximize" />
<Button Command="{x:Static SystemCommands.MinimizeWindowCommand}" Content="Minimize" />
<TabControl>
...
</TabControl>
</Canvas>
</Window>
And in your C# code-behind:
private void CommandBinding_CanExecute_1(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
}
private void CommandBinding_Executed_1(object sender, ExecutedRoutedEventArgs e)
{
SystemCommands.CloseWindow(this);
}
private void CommandBinding_Executed_2(object sender, ExecutedRoutedEventArgs e)
{
SystemCommands.MaximizeWindow(this);
}
private void CommandBinding_Executed_3(object sender, ExecutedRoutedEventArgs e)
{
SystemCommands.MinimizeWindow(this);
}
This will make close/maximize/minimize works exactly like with a regular window.
Of course, you may want to use System.Windows.Interactivity
to move the C# into a ViewModel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With