WPF 어플리케이션을 Windows 7에서도 메트로 스타일로 할 수 있습니까? (Windows Chrome / Theming / Theme )
새로운 Office Suite와 Visual Studio의 윈도우 크롬이 마음에 듭니다.

물론 아직 Windows 7용 어플리케이션을 개발하고 있습니다만, 이 스타일을 에뮬레이트 할 수 있는 빠르고 쉬운 방법(WPF 스타일 또는 Windows 라이브러리 읽기)이 있을까요?예전에 윈도우 크롬 스타일링을 몇 번 해봤는데, 모양과 동작에 맞게 하는 것은 매우 까다롭습니다.
WPF 응용 프로그램에 "Modern UI" 모양과 느낌을 추가할 수 있는 기존 템플릿이나 라이브러리가 있는지 알고 있는 사람이 있습니까?
내가 한 일은 나만의 창과 스타일을 만드는 것이었다.모든 것을 제어하고 싶기 때문에 윈도우를 사용하기만 하는 외부 라이브러리는 원하지 않습니다.이미 언급한 MahApps를 살펴보았습니다.메트로 온 깃허브

또한 GitHub에서 매우 멋진 Modern UI. (.NET 4.5만 해당)

하나 더 있는데 이거 진짜 안 먹어봤어.

이 옷을 입었을 때 스타일은 정말 쉬웠어요.이제 내 창문이 생겼고 XAML로 내가 원하는 걸 할 수 있어그게 내가 내 일을 하게 된 주된 이유야그리고 당신을 위해 하나 더 만들었습니다:) 아마도 저는 Modern UI를 익히지 않으면 할 수 없다고 말해야 할 것 같습니다.VS2012 Window처럼 보이게 하려고 했어요.이렇게 생겼어요.

다음은 코드입니다(타깃 대상임을 주의해 주십시오).NET4.5)
public class MyWindow : Window
{
public MyWindow()
{
this.CommandBindings.Add(new CommandBinding(SystemCommands.CloseWindowCommand, this.OnCloseWindow));
this.CommandBindings.Add(new CommandBinding(SystemCommands.MaximizeWindowCommand, this.OnMaximizeWindow, this.OnCanResizeWindow));
this.CommandBindings.Add(new CommandBinding(SystemCommands.MinimizeWindowCommand, this.OnMinimizeWindow, this.OnCanMinimizeWindow));
this.CommandBindings.Add(new CommandBinding(SystemCommands.RestoreWindowCommand, this.OnRestoreWindow, this.OnCanResizeWindow));
}
private void OnCanResizeWindow(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = this.ResizeMode == ResizeMode.CanResize || this.ResizeMode == ResizeMode.CanResizeWithGrip;
}
private void OnCanMinimizeWindow(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = this.ResizeMode != ResizeMode.NoResize;
}
private void OnCloseWindow(object target, ExecutedRoutedEventArgs e)
{
SystemCommands.CloseWindow(this);
}
private void OnMaximizeWindow(object target, ExecutedRoutedEventArgs e)
{
SystemCommands.MaximizeWindow(this);
}
private void OnMinimizeWindow(object target, ExecutedRoutedEventArgs e)
{
SystemCommands.MinimizeWindow(this);
}
private void OnRestoreWindow(object target, ExecutedRoutedEventArgs e)
{
SystemCommands.RestoreWindow(this);
}
}
그리고 여기 자원:
<BooleanToVisibilityConverter x:Key="bool2VisibilityConverter" />
<Color x:Key="WindowBackgroundColor">#FF2D2D30</Color>
<Color x:Key="HighlightColor">#FF3F3F41</Color>
<Color x:Key="BlueColor">#FF007ACC</Color>
<Color x:Key="ForegroundColor">#FFF4F4F5</Color>
<SolidColorBrush x:Key="WindowBackgroundColorBrush" Color="{StaticResource WindowBackgroundColor}"/>
<SolidColorBrush x:Key="HighlightColorBrush" Color="{StaticResource HighlightColor}"/>
<SolidColorBrush x:Key="BlueColorBrush" Color="{StaticResource BlueColor}"/>
<SolidColorBrush x:Key="ForegroundColorBrush" Color="{StaticResource ForegroundColor}"/>
<Style x:Key="WindowButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Foreground" Value="{DynamicResource ForegroundColorBrush}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Padding" Value="1" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter x:Name="contentPresenter"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{StaticResource HighlightColorBrush}" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="{DynamicResource BlueColorBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="contentPresenter" Property="Opacity" Value=".5" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="MyWindowStyle" TargetType="local:MyWindow">
<Setter Property="Foreground" Value="{DynamicResource ForegroundColorBrush}" />
<Setter Property="Background" Value="{DynamicResource WindowBackgroundBrush}"/>
<Setter Property="ResizeMode" Value="CanResizeWithGrip" />
<Setter Property="UseLayoutRounding" Value="True" />
<Setter Property="TextOptions.TextFormattingMode" Value="Display" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:MyWindow">
<Border x:Name="WindowBorder" Margin="{Binding Source={x:Static SystemParameters.WindowNonClientFrameThickness}}" Background="{StaticResource WindowBackgroundColorBrush}">
<Grid>
<Border BorderThickness="1">
<AdornerDecorator>
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="25" />
<RowDefinition Height="*" />
<RowDefinition Height="15" />
</Grid.RowDefinitions>
<ContentPresenter Grid.Row="1" Grid.RowSpan="2" Margin="7"/>
<Rectangle x:Name="HeaderBackground" Height="25" Fill="{DynamicResource WindowBackgroundColorBrush}" VerticalAlignment="Top" Grid.Row="0"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" WindowChrome.IsHitTestVisibleInChrome="True" Grid.Row="0">
<Button Command="{Binding Source={x:Static SystemCommands.MinimizeWindowCommand}}" ToolTip="minimize" Style="{StaticResource WindowButtonStyle}">
<Button.Content>
<Grid Width="30" Height="25" RenderTransform="1,0,0,1,0,1">
<Path Data="M0,6 L8,6 Z" Width="8" Height="7" VerticalAlignment="Center" HorizontalAlignment="Center"
Stroke="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}" StrokeThickness="2" />
</Grid>
</Button.Content>
</Button>
<Grid Margin="1,0,1,0">
<Button x:Name="Restore" Command="{Binding Source={x:Static SystemCommands.RestoreWindowCommand}}" ToolTip="restore" Visibility="Collapsed" Style="{StaticResource WindowButtonStyle}">
<Button.Content>
<Grid Width="30" Height="25" UseLayoutRounding="True" RenderTransform="1,0,0,1,.5,.5">
<Path Data="M2,0 L8,0 L8,6 M0,3 L6,3 M0,2 L6,2 L6,8 L0,8 Z" Width="8" Height="8" VerticalAlignment="Center" HorizontalAlignment="Center"
Stroke="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}" StrokeThickness="1" />
</Grid>
</Button.Content>
</Button>
<Button x:Name="Maximize" Command="{Binding Source={x:Static SystemCommands.MaximizeWindowCommand}}" ToolTip="maximize" Style="{StaticResource WindowButtonStyle}">
<Button.Content>
<Grid Width="31" Height="25">
<Path Data="M0,1 L9,1 L9,8 L0,8 Z" Width="9" Height="8" VerticalAlignment="Center" HorizontalAlignment="Center"
Stroke="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}" StrokeThickness="2" />
</Grid>
</Button.Content>
</Button>
</Grid>
<Button Command="{Binding Source={x:Static SystemCommands.CloseWindowCommand}}" ToolTip="close" Style="{StaticResource WindowButtonStyle}">
<Button.Content>
<Grid Width="30" Height="25" RenderTransform="1,0,0,1,0,1">
<Path Data="M0,0 L8,7 M8,0 L0,7 Z" Width="8" Height="7" VerticalAlignment="Center" HorizontalAlignment="Center"
Stroke="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}" StrokeThickness="1.5" />
</Grid>
</Button.Content>
</Button>
</StackPanel>
<TextBlock x:Name="WindowTitleTextBlock" Grid.Row="0" Text="{TemplateBinding Title}" HorizontalAlignment="Left" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" Margin="8 -1 0 0" FontSize="16" Foreground="{TemplateBinding Foreground}"/>
<Grid Grid.Row="2">
<Path x:Name="ResizeGrip" Visibility="Collapsed" Width="12" Height="12" Margin="1" HorizontalAlignment="Right"
Stroke="{StaticResource BlueColorBrush}" StrokeThickness="1" Stretch="None" Data="F1 M1,10 L3,10 M5,10 L7,10 M9,10 L11,10 M2,9 L2,11 M6,9 L6,11 M10,9 L10,11 M5,6 L7,6 M9,6 L11,6 M6,5 L6,7 M10,5 L10,7 M9,2 L11,2 M10,1 L10,3" />
</Grid>
</Grid>
</AdornerDecorator>
</Border>
<Border BorderBrush="{StaticResource BlueColorBrush}" BorderThickness="1" Visibility="{Binding IsActive, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Converter={StaticResource bool2VisibilityConverter}}" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="WindowState" Value="Maximized">
<Setter TargetName="Maximize" Property="Visibility" Value="Collapsed" />
<Setter TargetName="Restore" Property="Visibility" Value="Visible" />
<Setter TargetName="LayoutRoot" Property="Margin" Value="7" />
</Trigger>
<Trigger Property="WindowState" Value="Normal">
<Setter TargetName="Maximize" Property="Visibility" Value="Visible" />
<Setter TargetName="Restore" Property="Visibility" Value="Collapsed" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="ResizeMode" Value="CanResizeWithGrip" />
<Condition Property="WindowState" Value="Normal" />
</MultiTrigger.Conditions>
<Setter TargetName="ResizeGrip" Property="Visibility" Value="Visible" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="WindowChrome.WindowChrome">
<Setter.Value>
<WindowChrome CornerRadius="0" GlassFrameThickness="1" UseAeroCaptionButtons="False" />
</Setter.Value>
</Setter>
</Style>
결국 제가 선택한 솔루션은 MahApps였습니다.Metro(github)는 (현재 2개의 소프트웨어에서 사용 중) 훌륭한 UI 키트(Oliver Vogel의 제안으로 인정)를 검토하고 있습니다.

애플리케이션 스킨은 거의 필요 없으며 표준 Windows 8 컨트롤이 적용되어 있습니다.매우 튼튼합니다.

Nuget에서는 다음 버전을 사용할 수 있습니다.
MahApps를 설치할 수 있습니다.Metro via Nuget(GUI를 사용하여 Nuget 참조 관리) (프로젝트를 마우스 오른쪽 버튼으로 클릭하고 'MahApps'를 검색합니다).Metro') 또는 콘솔 경유:
PM > MahApp 설치 패키지.메트로
상업적인 용도로도 무료입니다.
2013년 10월 29일 갱신:
Github 버전의 MahApps를 발견했습니다.Metro는 현재 Nuget 버전에서는 사용할 수 없는 다음과 같은 컨트롤과 스타일을 갖추고 있습니다.
데이터 ID:

창 청소:

플라이아웃:

타일:

github 저장소는 매우 활성화되어 있으며 상당한 양의 사용자 기여가 있습니다.확인해 볼 것을 권합니다.
매우 활동적인 유지보수가 있어 멋지고 무료입니다!

현재 MUI에 몇 가지 프로젝트를 위탁하고 있는데, 첫 번째(그리고 두 번째) 인상은 정말 대단해요!
MUI의 동작을 확인하려면 MUI 기반의 XAML Spy를 다운로드하십시오.
편집: WPF에서 몇 달 동안 모던 UI를 사용했는데 마음에 들어요!
위의 출처와 함께 Kapitan Miliko의 답변을 바탕으로 다음 사항을 사용하도록 변경합니다.

[ Minimize ] 、 [ Restore ] / [ Maximize ] 、 [ Close ]버튼에는 패스 데이터 포인트보다 Marlett 글꼴을 사용하는 것이 좋습니다.
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" WindowChrome.IsHitTestVisibleInChrome="True" Grid.Row="0">
<Button Command="{Binding Source={x:Static SystemCommands.MinimizeWindowCommand}}" ToolTip="minimize" Style="{StaticResource WindowButtonStyle}">
<Button.Content>
<Grid Width="30" Height="25">
<TextBlock Text="0" FontFamily="Marlett" FontSize="14" VerticalAlignment="Center" HorizontalAlignment="Center" Padding="3.5,0,0,3" />
</Grid>
</Button.Content>
</Button>
<Grid Margin="1,0,1,0">
<Button x:Name="Restore" Command="{Binding Source={x:Static SystemCommands.RestoreWindowCommand}}" ToolTip="restore" Visibility="Collapsed" Style="{StaticResource WindowButtonStyle}">
<Button.Content>
<Grid Width="30" Height="25" UseLayoutRounding="True">
<TextBlock Text="2" FontFamily="Marlett" FontSize="14" VerticalAlignment="Center" HorizontalAlignment="Center" Padding="2,0,0,1" />
</Grid>
</Button.Content>
</Button>
<Button x:Name="Maximize" Command="{Binding Source={x:Static SystemCommands.MaximizeWindowCommand}}" ToolTip="maximize" Style="{StaticResource WindowButtonStyle}">
<Button.Content>
<Grid Width="31" Height="25">
<TextBlock Text="1" FontFamily="Marlett" FontSize="14" VerticalAlignment="Center" HorizontalAlignment="Center" Padding="2,0,0,1" />
</Grid>
</Button.Content>
</Button>
</Grid>
<Button Command="{Binding Source={x:Static SystemCommands.CloseWindowCommand}}" ToolTip="close" Style="{StaticResource WindowButtonStyle}">
<Button.Content>
<Grid Width="30" Height="25">
<TextBlock Text="r" FontFamily="Marlett" FontSize="14" VerticalAlignment="Center" HorizontalAlignment="Center" Padding="0,0,0,1" />
</Grid>
</Button.Content>
</Button>
지불하실 의향이 있으시다면 WPF용 Telerik Components를 적극 추천합니다.뛰어난 스타일/테마를 제공하며 Office 2013과 Windows 8(편집: 및 Visual Studio 2013 테마 스타일) 모두 특정 테마가 있습니다.그러나 실제로는 스타일뿐만 아니라 훨씬 더 많은 컨트롤이 제공되므로 매우 유용합니다.
동작하는 모습을 다음에 나타냅니다(텔레릭샘플에서 캡처한 스크린샷).


다음은 Telerik 이그제큐티브 대시보드 샘플(첫 번째 스크린샷)과 CRM 대시보드(두 번째 스크린샷)에 대한 링크입니다.
30일 평가판을 제공하니 한번 시도해 보세요!
이 WPF 메트로 스타일의 창문에 광택 테두리가 옵션으로 붙어 있습니다.
이것은 Microsoft 이외의 라이브러리를 사용하지 않는 스탠드아론 어플리케이션입니다.창문들.쉘(포함)을 통해 광택 테두리를 옵션으로 갖춘 메트로 스타일의 창을 만들 수 있습니다.
XP(.NET4)까지 Windows를 지원합니다.
언급URL : https://stackoverflow.com/questions/13592326/making-wpf-applications-look-metro-styled-even-in-windows-7-window-chrome-t
'programing' 카테고리의 다른 글
| 하나의 문장에서 여러 항목을 목록에서 제거하려면 어떻게 해야 합니까? (0) | 2023.04.15 |
|---|---|
| UITableView에서 빈 셀 사이의 구분 기호를 강제로 숨길 수 있습니까? (0) | 2023.04.15 |
| 데이터 프레임 목록을 작성하려면 어떻게 해야 합니까? (0) | 2023.04.10 |
| C#을 사용하여 파일 전체를 문자열로 읽는 방법 (0) | 2023.04.10 |
| WPF - 표준 버튼을 사용하여 위 화살표와 아래 화살표 버튼을 만듭니다. (0) | 2023.04.10 |