关闭

IntegerUpDown控件自定义样式

1308人阅读 评论(0) 收藏 举报
分类:
<Style TargetType="{x:Type xctk:IntegerUpDown}">
            <Style.Resources>
                <Style TargetType="{x:Type xctk:WatermarkTextBox}"
               BasedOn="{StaticResource {x:Type xctk:WatermarkTextBox}}">
                    <Setter Property="VerticalAlignment" Value="Stretch"/>
                    <Setter Property="HorizontalAlignment" Value="Stretch"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate  TargetType="{x:Type xctk:WatermarkTextBox}">
                                <Border x:Name="Border" BorderThickness="0,0,1,0" MinHeight="20"  BorderBrush="{TemplateBinding BorderBrush}" Background="#434245" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="Stretch">
                                    <Grid>
                                        <ScrollViewer x:Name="PART_ContentHost" Style="{DynamicResource ScorllStyle}"
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                        <ContentPresenter x:Name="PART_WatermarkHost" Content="{TemplateBinding Watermark}" ContentTemplate="{TemplateBinding WatermarkTemplate}"
                              VerticalAlignment="Center" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              IsHitTestVisible="False" Visibility="Collapsed" />
                                    </Grid>
                                </Border>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
                <!--上下箭头Style-->
                <Style TargetType="{x:Type xctk:ButtonSpinner}">
                    <Setter Property="VerticalAlignment" Value="Center"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type xctk:ButtonSpinner}">
                                <Border x:Name="Border" BorderBrush="White" BorderThickness="1" Background="red" SnapsToDevicePixels="True">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <ContentPresenter Content="{TemplateBinding Content}" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                        <Grid Grid.Column="1" Width="19">
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="*"/>
                                                <RowDefinition Height="*"/>
                                            </Grid.RowDefinitions>
                                            <RepeatButton  x:Name="PART_IncreaseButton" IsTabStop="{TemplateBinding IsTabStop}">
                                            	 <RepeatButton.ContentTemplate>
                                                    <DataTemplate>
                                                        <Path Data="M0,3C0,3 0,4 0,4 0,4 3,4 3,4 3,4 3,3 3,3 3,3 4,3 4,3 4,3 4,4 4,4 4,4 7,4 7,4 7,4 7,3 7,3 7,3 6,3 6,3 6,3 6,2 6,2 6,2 5,2 5,2 5,2 5,1 5,1 5,1 4,1 4,1 4,1 4,0 4,0 4,0 3,0 3,0 3,0 3,1 3,1 3,1 2,1 2,1 2,1 2,2 2,2 2,2 1,2 1,2 1,2 1,3 1,3 1,3 0,3 0,3z" Focusable="False" Fill="White" HorizontalAlignment="Center" SnapsToDevicePixels="True" VerticalAlignment="Center"/>
                                                    </DataTemplate>

                                                </RepeatButton.ContentTemplate>
                                               
                                            </RepeatButton>
                                            <RepeatButton x:Name="PART_DecreaseButton" IsTabStop="{TemplateBinding IsTabStop}" Grid.Row="1" >
                                            	 <RepeatButton.ContentTemplate>
                                                    <DataTemplate>
                                                        <Path Data="M0,1C0,1 0,0 0,0 0,0 3,0 3,0 3,0 3,1 3,1 3,1 4,1 4,1 4,1 4,0 4,0 4,0 7,0 7,0 7,0 7,1 7,1 7,1 6,1 6,1 6,1 6,2 6,2 6,2 5,2 5,2 5,2 5,3 5,3 5,3 4,3 4,3 4,3 4,4 4,4 4,4 3,4 3,4 3,4 3,3 3,3 3,3 2,3 2,3 2,3 2,2 2,2 2,2 1,2 1,2 1,2 1,1 1,1 1,1 0,1 0,1z" Focusable="False" Fill="White" HorizontalAlignment="Center" Height="4" SnapsToDevicePixels="True" VerticalAlignment="Center" Width="7"/>
                                                    </DataTemplate>
                                                </RepeatButton.ContentTemplate>
                                            </RepeatButton>
                                        </Grid>
                                    </Grid>
                                </Border>
                                <ControlTemplate.Triggers>
                                    <Trigger Property="IsEnabled" SourceName="PART_IncreaseButton" Value="False">
                                        <!--BorderBrush="#353535"  BorderThickness="0.1" Background="Transparent"-->
                                        <Setter Property="Background" Value="gray"/>
                                    </Trigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Style.Resources>
            <Setter Property="Margin" Value="2"/>
            <Setter Property="VerticalAlignment" Value="Stretch"/>
            <Setter Property="HorizontalAlignment" Value="Stretch"/>
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="Padding" Value="0"/>
        </Style>
		

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:103918次
    • 积分:1383
    • 等级:
    • 排名:千里之外
    • 原创:36篇
    • 转载:0篇
    • 译文:1篇
    • 评论:24条
    文章分类
    最新评论