添加项目文件。
This commit is contained in:
43
Wpf.Ui.Extend/Controls/FluentWindowEx/FluentWindowEx.xaml
Normal file
43
Wpf.Ui.Extend/Controls/FluentWindowEx/FluentWindowEx.xaml
Normal file
@@ -0,0 +1,43 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="http://schemas.lepo.co/wpfui/2022/xaml"
|
||||
xmlns:exc="clr-namespace:Wpf.Ui.Extend.Controls">
|
||||
<Style x:Key="DefaultFluentWindowExStyle" TargetType="{x:Type exc:FluentWindowEx}">
|
||||
<Setter Property="Background" Value="{DynamicResource WindowBackground}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource WindowForeground}" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="MinWidth" Value="280" />
|
||||
<Setter Property="Margin" Value="0" />
|
||||
<Setter Property="Padding" Value="0" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
|
||||
<Setter Property="FontWeight" Value="Normal" />
|
||||
<Setter Property="UseLayoutRounding" Value="True" />
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="OverridesDefaultStyle" Value="True" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type exc:FluentWindowEx}">
|
||||
<DockPanel>
|
||||
<controls:TitleBar
|
||||
Title="{TemplateBinding Title}"
|
||||
Background="{TemplateBinding Background}"
|
||||
DockPanel.Dock="Top"
|
||||
Icon="{TemplateBinding TitleIcon}" />
|
||||
<AdornerDecorator>
|
||||
<controls:ClientAreaBorder
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}">
|
||||
<ContentPresenter x:Name="ContentPresenter" />
|
||||
</controls:ClientAreaBorder>
|
||||
</AdornerDecorator>
|
||||
<!--<controls:SnackbarPresenter x:Name="SnackbarPresenter" DockPanel.Dock="Bottom" />-->
|
||||
</DockPanel>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style BasedOn="{StaticResource DefaultFluentWindowExStyle}" TargetType="{x:Type exc:FluentWindowEx}" />
|
||||
</ResourceDictionary>
|
||||
34
Wpf.Ui.Extend/Controls/FluentWindowEx/FluentWindowEx.xaml.cs
Normal file
34
Wpf.Ui.Extend/Controls/FluentWindowEx/FluentWindowEx.xaml.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Windows;
|
||||
|
||||
using Wpf.Ui.Controls;
|
||||
|
||||
namespace Wpf.Ui.Extend.Controls;
|
||||
public class FluentWindowEx : FluentWindow
|
||||
{
|
||||
static FluentWindowEx()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(FluentWindowEx), new FrameworkPropertyMetadata(typeof(FluentWindowEx)));
|
||||
}
|
||||
public FluentWindowEx()
|
||||
{
|
||||
//将指定的属性与资源字典中的资源关联起来
|
||||
SetResourceReference(StyleProperty,typeof(FluentWindowEx));
|
||||
}
|
||||
public IconElement TitleIcon
|
||||
{
|
||||
get { return (IconElement)GetValue(TitleIconProperty); }
|
||||
set { SetValue(TitleIconProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty TitleIconProperty =
|
||||
DependencyProperty.Register(nameof(TitleIcon), typeof(IconElement), typeof(FluentWindowEx), new PropertyMetadata(null));
|
||||
|
||||
//public override void OnApplyTemplate()
|
||||
//{
|
||||
// base.OnApplyTemplate();
|
||||
// var resources = Application.Current.Resources;
|
||||
// var style = Application.Current.FindResource("DefaultFluentWindowExStyle");
|
||||
// var style1 = Application.Current.FindResource(typeof(FluentWindowEx));
|
||||
// this.Style = (Style)FindResource(typeof(FluentWindowEx));
|
||||
//}
|
||||
}
|
||||
Reference in New Issue
Block a user