おそらく、ウィンドウの境界を削除して、自分でボタンを描画する必要があります。ボタンのクリックを自分で処理する必要があり (ウィンドウが最大化されたときに最大化も復元されることを忘れないでください)、ウィンドウのドラッグも自分で処理する必要があります。
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1"
Title="" WindowStyle="None" AllowsTransparency="True" Height="350" Width="525" DataContext="{Binding RelativeSource={RelativeSource Self}}"
>
<Grid>
<Grid Background="Silver">
<TabControl>
<TabItem Header="Tab 1"/>
<TabItem Header="Tab 2"/>
<TabItem Header="Tab 3"/>
</TabControl>
</Grid>
<StackPanel HorizontalAlignment="Right" VerticalAlignment="Top" Orientation="Horizontal" >
<Button Content="_" Width="30" Command="{Binding MinimizeCommand}"/>
<Button Content="-" Width="30" Command="{Binding MaximizeCommand}" />
<Button Content="x" Width="30" Command="{Binding CloseCommand}"/>
</StackPanel>
</Grid>
</Window>
ボタンに接続されているコマンドは、ウィンドウ内のコード ビハインドで定義されています。
public partial class MainWindow : Window
{
public ICommand CloseCommand
{
get { return (ICommand)GetValue(CloseCommandProperty); }
set { SetValue(CloseCommandProperty, value); }
}
public ICommand MinimizeCommand
{
get { return (ICommand)GetValue(MinimizeCommandProperty); }
set { SetValue(MinimizeCommandProperty, value); }
}
public ICommand MaximizeCommand
{
get { return (ICommand)GetValue(MaximizeCommandProperty); }
set { SetValue(MaximizeCommandProperty, value); }
}
public static readonly DependencyProperty CloseCommandProperty = DependencyProperty.Register("CloseCommand", typeof(ICommand), typeof(MainWindow), new PropertyMetadata(null));
public static readonly DependencyProperty MinimizeCommandProperty = DependencyProperty.Register("MinimizeCommand", typeof(ICommand), typeof(MainWindow), new PropertyMetadata(null));
public static readonly DependencyProperty MaximizeCommandProperty = DependencyProperty.Register("MaximizeCommand", typeof(ICommand), typeof(MainWindow), new PropertyMetadata(null));
public MainWindow()
{
InitializeComponent();
System.Windows.Interactivity.EventObserver a;
// Setup the commands.
CloseCommand = new RoutedCommand("CloseCommand", typeof(MainWindow));
MinimizeCommand = new RoutedCommand("MinimizeCommand", typeof(MainWindow));
MaximizeCommand = new RoutedCommand("MaximizeCommand", typeof(MainWindow));
// Put them in the windows command bindings.
this.CommandBindings.Add(new CommandBinding(CloseCommand, new ExecutedRoutedEventHandler((s, e) => this.Close()), new CanExecuteRoutedEventHandler((s, e) => { e.CanExecute = true; })));
this.CommandBindings.Add(new CommandBinding(MinimizeCommand, new ExecutedRoutedEventHandler((s, e) => this.WindowState = System.Windows.WindowState.Minimized), new CanExecuteRoutedEventHandler((s, e) => { e.CanExecute = true; })));
this.CommandBindings.Add(new CommandBinding(MaximizeCommand, new ExecutedRoutedEventHandler((s, e) => this.WindowState = System.Windows.WindowState.Maximized), new CanExecuteRoutedEventHandler((s, e) => { e.CanExecute = true; })));
}
protected override void OnMouseMove(MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
DragMove();
base.OnMouseMove(e);
}
}