IntegerUpDown控件自定义样式

<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>
		

阅读更多
个人分类: wpf
想对作者说点什么? 我来说一句

EdtiText自定义样式

2014年09月03日 1023KB 下载

很方便的自定义验证码控件

2009年05月19日 100KB 下载

wpf DataGrid 自定义样式

2010年08月02日 289KB 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭