首次提交

This commit is contained in:
GG Z
2026-02-23 10:28:26 +08:00
commit 3461bb9cb3
259 changed files with 22591 additions and 0 deletions

View File

@@ -0,0 +1,139 @@
<local:ModernWindow
x:Class="WpfAppTest.ModernWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ModernWpf.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:wpfapptest="clr-namespace:WpfAppTest"
Title="ModernWindow"
Width="800"
Height="450"
d:DataContext="{d:DesignInstance Type=wpfapptest:MainViewModel}"
d:Height="800"
Icon="{StaticResource Logo}"
Style="{StaticResource ModernWindowStyle}"
mc:Ignorable="d">
<Window.Resources>
<ResourceDictionary>
<ObjectDataProvider
x:Key="GenderEnumData"
MethodName="GetValues"
ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="wpfapptest:Gender" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</ResourceDictionary>
</Window.Resources>
<ScrollViewer>
<StackPanel Margin="20">
<!-- 5. TextBox -->
<TextBox Margin="0,0,0,15" local:ElementHelper.Watermark="请输入您的用户名">
<local:ElementHelper.Prefix>
<Path Data="{StaticResource IconUser}" Stroke="{StaticResource LightTextBrush}" />
</local:ElementHelper.Prefix>
</TextBox>
<local:ModernPasswordBox Margin="0,0,0,15" local:ElementHelper.Watermark="请输入密码">
<local:ElementHelper.Prefix>
<Path Data="{StaticResource IconLock}" Stroke="{StaticResource LightTextBrush}" />
</local:ElementHelper.Prefix>
</local:ModernPasswordBox>
<!-- 2. ComboBox (Searchable) -->
<local:SearchableComboBox
Margin="0,0,0,15"
local:ElementHelper.Watermark="搜索..."
IsEditable="True"
ItemsSource="{Binding Items}"
SelectedItem="{Binding SelectedItem}" />
<!-- 8. GroupBox with 6. CheckBox & 7. RadioButton -->
<GroupBox Margin="0,0,0,15" Header="设置选项">
<StackPanel Margin="5">
<CheckBox
Margin="0,5"
Content="记住我"
IsChecked="True" />
<CheckBox Margin="0,5" Content="自动登录" />
<Separator Margin="0,10" />
<RadioButton
Margin="0,5"
Content="普通用户"
GroupName="Role"
IsChecked="True" />
<RadioButton
Margin="0,5"
Content="管理员"
GroupName="Role" />
</StackPanel>
</GroupBox>
<!-- 4. Button with Icon -->
<Button
HorizontalAlignment="Left"
local:ElementHelper.Icon="M12,4L12,20M4,12L20,12"
Command="{Binding ConfirmCommand}"
Content="登 录" />
<DataGrid Margin="5" ItemsSource="{Binding Students}">
<DataGrid.Columns>
<DataGridCheckBoxColumn Binding="{Binding IsSelected}" Header="选择" />
<DataGridTextColumn Binding="{Binding Name}" Header="姓名" />
<DataGridTextColumn Binding="{Binding Age}" Header="年龄" />
<DataGridComboBoxColumn
Header="性别"
ItemsSource="{Binding Genders}"
SelectedItemBinding="{Binding Gender}" />
</DataGrid.Columns>
</DataGrid>
<DataGrid ColumnWidth="*" ItemsSource="{Binding Students}">
<DataGrid.Columns>
<!-- 1. 文本列:【必须】加上 EditingElementStyle -->
<DataGridTextColumn
Width="150"
Binding="{Binding Name}"
EditingElementStyle="{StaticResource ModernEditingTextBoxStyle}"
Header="姓名" />
<DataGridTextColumn
Width="80"
Binding="{Binding Age}"
EditingElementStyle="{StaticResource ModernEditingTextBoxStyle}"
Header="年龄" />
<!-- 2. 复选框列:(TemplateColumn 不需要 EditingElementStyle因为它直接包含 CheckBox) -->
<DataGridTemplateColumn
Width="80"
Header="已选"
SortMemberPath="IsSelected">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsChecked="{Binding IsSelected, UpdateSourceTrigger=PropertyChanged}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<!-- 3. 下拉框列:【必须】加上 EditingElementStyle -->
<DataGridComboBoxColumn
Width="120"
EditingElementStyle="{StaticResource ModernEditingComboBoxStyle}"
Header="性别"
ItemsSource="{Binding Source={StaticResource GenderEnumData}}"
SelectedItemBinding="{Binding Gender}">
<!-- 非编辑状态下的外观优化 -->
</DataGridComboBoxColumn>
</DataGrid.Columns>
</DataGrid>
<wpfapptest:RebarTextBlock RebarText="{Binding SampleText, Mode=TwoWay}" />
<!--<TextBlock FontFamily="{StaticResource SJQY}" Text="CCCC" />-->
</StackPanel>
</ScrollViewer>
</local:ModernWindow>