|
|
@@ -0,0 +1,135 @@
|
|
|
+<Window x:Class="MvvmScaffoldFrame48.MainWindow"
|
|
|
+ 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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
|
+ xmlns:local="clr-namespace:MvvmScaffoldFrame48"
|
|
|
+ mc:Ignorable="d"
|
|
|
+ Title="MainWindow" Height="450" Width="800">
|
|
|
+ <Grid>
|
|
|
+ <Grid.ColumnDefinitions>
|
|
|
+ <ColumnDefinition Width="*" />
|
|
|
+ <ColumnDefinition Width="*" />
|
|
|
+ </Grid.ColumnDefinitions>
|
|
|
+ <StackPanel Grid.Column="0">
|
|
|
+ <ToolBar>
|
|
|
+ <Label Content="姓名:"></Label>
|
|
|
+ <TextBox Text="{Binding Name}" Width="50"></TextBox>
|
|
|
+ <Label Content="邮箱:"></Label>
|
|
|
+ <TextBox Text="{Binding Email}" Width="100"></TextBox>
|
|
|
+ <Button Content="添加"
|
|
|
+ Command="{Binding AddUserCommand }"></Button>
|
|
|
+ <Button Content="测试"
|
|
|
+ Command="{Binding TestCommand }"></Button>
|
|
|
+ </ToolBar>
|
|
|
+ <StackPanel>
|
|
|
+ <DataGrid ItemsSource="{Binding Users}"></DataGrid>
|
|
|
+
|
|
|
+ </StackPanel>
|
|
|
+ </StackPanel>
|
|
|
+ <Grid Grid.Column="1">
|
|
|
+ <StackPanel Height="30" Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Center">
|
|
|
+ <Label Content="红绿灯演示"></Label>
|
|
|
+ <Ellipse Width="20" Height="20" Margin="48,0,0,0" >
|
|
|
+ <Ellipse.Style>
|
|
|
+ <Style TargetType="Ellipse">
|
|
|
+ <Setter Property="Fill" Value="Red" />
|
|
|
+ <Style.Triggers>
|
|
|
+ <DataTrigger Binding="{Binding StaticTest}" Value="True">
|
|
|
+ <Setter Property="Fill" Value="Green" />
|
|
|
+ </DataTrigger>
|
|
|
+ </Style.Triggers>
|
|
|
+ </Style>
|
|
|
+ </Ellipse.Style>
|
|
|
+ </Ellipse>
|
|
|
+ </StackPanel>
|
|
|
+ <StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,40,0,0" Height="30">
|
|
|
+ <Label Content="可以更改背景颜色的ComboBox:"/>
|
|
|
+ <ComboBox Height="40" Width="140" ItemsSource="{Binding FormulationItems}" HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalContentAlignment="Center" FontSize="20">
|
|
|
+ <ComboBox.Template>
|
|
|
+ <ControlTemplate TargetType="ComboBox">
|
|
|
+ <Grid>
|
|
|
+ <ToggleButton
|
|
|
+ Foreground="White"
|
|
|
+ IsChecked="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"
|
|
|
+ ClickMode="Press">
|
|
|
+ <ToggleButton.Template>
|
|
|
+ <ControlTemplate TargetType="ToggleButton">
|
|
|
+ <Border x:Name="Border" Background="#FF0087FF" BorderBrush="#FFABADB3" BorderThickness="1">
|
|
|
+ <Grid>
|
|
|
+ <Grid.ColumnDefinitions>
|
|
|
+ <ColumnDefinition />
|
|
|
+ <ColumnDefinition Width="20" />
|
|
|
+ </Grid.ColumnDefinitions>
|
|
|
+ <ContentPresenter Grid.Column="0" Margin="3" />
|
|
|
+ <Path x:Name="Arrow" Grid.Column="1"
|
|
|
+ Fill="White"
|
|
|
+ HorizontalAlignment="Center"
|
|
|
+ VerticalAlignment="Center"
|
|
|
+ Data="M 0 0 L 4 4 L 8 0 Z" />
|
|
|
+ </Grid>
|
|
|
+ </Border>
|
|
|
+ <ControlTemplate.Triggers>
|
|
|
+ <Trigger Property="IsMouseOver" Value="True">
|
|
|
+ <Setter TargetName="Border" Property="Background" Value="LightBlue" />
|
|
|
+ </Trigger>
|
|
|
+ </ControlTemplate.Triggers>
|
|
|
+ </ControlTemplate>
|
|
|
+ </ToggleButton.Template>
|
|
|
+ </ToggleButton>
|
|
|
+ <ContentPresenter x:Name="ContentSite"
|
|
|
+ IsHitTestVisible="False"
|
|
|
+ Content="{TemplateBinding SelectionBoxItem}"
|
|
|
+ ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
|
|
|
+ Margin="3,3,23,3"
|
|
|
+ VerticalAlignment="Center"
|
|
|
+ HorizontalAlignment="Left"
|
|
|
+ TextBlock.Foreground="White"/>
|
|
|
+ <Popup x:Name="Popup"
|
|
|
+ Placement="Bottom"
|
|
|
+ IsOpen="{TemplateBinding IsDropDownOpen}"
|
|
|
+ AllowsTransparency="True"
|
|
|
+ Focusable="False"
|
|
|
+ PopupAnimation="Slide">
|
|
|
+ <Border x:Name="DropDownBorder"
|
|
|
+ Background="#FF0087FF"
|
|
|
+ BorderBrush="#FF0087FF"
|
|
|
+ BorderThickness="1">
|
|
|
+ <ScrollViewer Margin="0,3,0,3"
|
|
|
+ SnapsToDevicePixels="True">
|
|
|
+ <ItemsPresenter KeyboardNavigation.DirectionalNavigation="Contained" />
|
|
|
+ </ScrollViewer>
|
|
|
+ </Border>
|
|
|
+ </Popup>
|
|
|
+ </Grid>
|
|
|
+ </ControlTemplate>
|
|
|
+ </ComboBox.Template>
|
|
|
+
|
|
|
+ <ComboBox.ItemContainerStyle>
|
|
|
+ <Style TargetType="ComboBoxItem">
|
|
|
+ <Setter Property="Background" Value="#FF0087FF" />
|
|
|
+ <Setter Property="Foreground" Value="White" />
|
|
|
+ <Style.Triggers>
|
|
|
+ <Trigger Property="IsHighlighted" Value="True">
|
|
|
+ <Setter Property="Background" Value="LightBlue" />
|
|
|
+ </Trigger>
|
|
|
+ </Style.Triggers>
|
|
|
+ </Style>
|
|
|
+ </ComboBox.ItemContainerStyle>
|
|
|
+ </ComboBox>
|
|
|
+ </StackPanel>
|
|
|
+ <StackPanel Orientation ="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,80,0,0">
|
|
|
+ <Label Content="圆角按钮:"/>
|
|
|
+ <Button Content="圆角按钮" BorderThickness="1" HorizontalAlignment="Right" VerticalAlignment="Top" Width="100" Height="30" Background="#FF0123FF" FontWeight="Bold" FontSize="20" Foreground="White" Cursor="Hand">
|
|
|
+ <Button.Template>
|
|
|
+ <ControlTemplate TargetType="Button">
|
|
|
+ <Border CornerRadius="5" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
|
|
|
+ <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
|
|
+ </Border>
|
|
|
+ </ControlTemplate>
|
|
|
+ </Button.Template>
|
|
|
+ </Button>
|
|
|
+ </StackPanel>
|
|
|
+ </Grid>
|
|
|
+ </Grid>
|
|
|
+</Window>
|