| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <Page x:Class="MvvmScaffoldFrame48.WPFPage.CustomControlPage"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:local="clr-namespace:MvvmScaffoldFrame48.WPFPage"
- mc:Ignorable="d"
- d:DesignHeight="450" d:DesignWidth="800"
- Title="CustomControlPage">
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="*" />
- <ColumnDefinition Width="*" />
- </Grid.ColumnDefinitions>
- <Grid Grid.Column="0">
- <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" Command="{Binding TestCommand}">
- <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>
- <StackPanel Orientation ="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,120,0,0">
- <Label Content="悬浮提示框:"/>
- <Button Content="悬浮提示框" Name="PopupBtn" BorderThickness="1" HorizontalAlignment="Right" VerticalAlignment="Top" Width="100" Height="30" Click="PopupBtn_Click"/>
- <Popup Name="myPopup" Placement="Mouse" AllowsTransparency="True">
- <Border Background="LightYellow" BorderBrush="Gray" BorderThickness="1">
- <TextBlock Text="这是一个悬浮提示" Padding="10"/>
- </Border>
- </Popup>
- </StackPanel>
- <StackPanel Orientation ="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,160,0,0">
- <Label Content="悬浮窗口:"/>
- <Button Content="悬浮窗口" Name="FloatBtn" BorderThickness="1" HorizontalAlignment="Right" VerticalAlignment="Top" Width="100" Height="30" Click="FloatBtn_Click"/>
- </StackPanel>
- </Grid>
- </Grid>
- </Page>
|