아마도 창 테두리를 제거하고 직접 단추를 그려야 할 것입니다. 버튼 클릭을 직접 처리해야합니다 (최대화가 창을 최대화 할 때 복원하는 것도 잊지 마세요). 창을 직접 드래그 할 수도 있습니다.
<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>
당신이 버튼에 매여 볼 수있는 명령
가 창에 뒤에 코드에 정의되어 있습니다. 당신은 제목 표시 줄 영역으로 이동 탭, WPF에서 멋진 유리 창문을 그릴 할 수있는
WPF Shell Integration library라고 마이크로 소프트에서 지금 소멸 프로젝트는이
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);
}
}
+1, 왜냐하면 명령 대신 클릭 이벤트를 사용하여 창 관리 코드를 처리하기 때문입니다. – Rachel
mvvm을 살펴볼 때까지는 UI가 어떻게 보이는지 알지 못합니다. – Andy
UI 용 코드 만 제공하는 MVVM의 코드 숨김을 사용하면 문제가 없으며 비즈니스/응용 프로그램 논리가 없습니다. 나는 UI를 UI에 맞게 조작하는 것을 고려할 것이다. MVVM을 사용할 때 코드 숨김에 넣는 것이 좋다. :) – Rachel