当前位置:编程学习 > C#/ASP.NET >>

自己写的ResourceDictionary

自己写的ResourceDictionary,插入App.Xaml里App.Resources下就可以使用,定义过的空间全会变成这种样式。
写了一些“弹来弹去”的控件,求抓BUG
另:实在找不到Xaml的选项,就用Html代替吧。
[code=HTML]<ResourceDictionary>
            <Style TargetType="Button">
                <Setter Property="OverridesDefaultStyle" Value="True" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Button">
                            <Grid>
                                <Border Name="BackBorder" BorderThickness="3" CornerRadius="5" BorderBrush="Yellow" RenderTransformOrigin="0.5,0.5" Background="Orange">
                                    <Border.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform ScaleX="1" ScaleY="1" />
                                            <RotateTransform Angle="0" />
                                        </TransformGroup>
                                    </Border.RenderTransform>
                                    <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
                                </Border>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup Name="CommonStates">
                                        <VisualState Name="Normal">
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.2" />
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[0].ScaleX" To="1" Duration="0:0:0.2" DecelerationRatio="1" />
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[0].ScaleY" To="1" Duration="0:0:0.2" DecelerationRatio="1" />
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[1].Angle" To="0" Duration="0:0:0.2" DecelerationRatio="1" />
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState Name="MouseOver">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[0].ScaleX">
                                                    <DoubleKeyFrameCollection>
                                                        <EasingDoubleKeyFrame Value="1.5" KeyTime="0:0:0.1" />
                                                        <EasingDoubleKeyFrame Value="1.1" KeyTime="0:0:0.2" />
                                                        <EasingDoubleKeyFrame Value="1.2" KeyTime="0:0:0.3" />
                                                    </DoubleKeyFrameCollection>
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[0].ScaleY">
                                                    <DoubleKeyFrameCollection>
                                                        <EasingDoubleKeyFrame Value="1.5" KeyTime="0:0:0.1" />
                                                        <EasingDoubleKeyFrame Value="1.1" KeyTime="0:0:0.2" />
                                                        <EasingDoubleKeyFrame Value="1.2" KeyTime="0:0:0.3" />
                                                    </DoubleKeyFrameCollection>
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[1].Angle" To="4" Duration="0:0:0.1" DecelerationRatio="1" />
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState Name="Pressed">
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[0].ScaleX" To="0.9" Duration="0:0:0.2" DecelerationRatio="1" />
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[0].ScaleY" To="0.9" Duration="0:0:0.2" DecelerationRatio="1" />
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[1].Angle" To="4" Duration="0:0:0.2" DecelerationRatio="1" />
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState Name="Disabled">
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="Opacity" To="0.5" Duration="0:0:0.2" />
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="MinHeight" Value="50" />
                <Setter Property="MinWidth" Value="100" />
                <Setter Property="FontSize" Value="25" />
                <Setter Property="FontFamily" Value="Comic Sans MS" />
            </Style>
             --------------------编程问答-------------------- <Style TargetType="RadioButton">
                <Setter Property="OverridesDefaultStyle" Value="True" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="RadioButton">
                            <Grid>
                                <Border BorderThickness="3" CornerRadius="5" Background="Orange" RenderTransformOrigin="0.5,0.5" Name="BackBorder" BorderBrush="Yellow">
                                    <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
                                    <Border.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform ScaleX="1" ScaleY="1" />
                                            <RotateTransform Angle="0" />
                                        </TransformGroup>
                                    </Border.RenderTransform>
                                </Border>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup Name="CommonStates">
                                        <VisualState Name="Normal">
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[0].ScaleX" To="1" Duration="0:0:0.2" DecelerationRatio="1" />
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[0].ScaleY" To="1" Duration="0:0:0.2" DecelerationRatio="1" />
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.2" />
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState Name="MouseOver">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[0].ScaleX">
                                                    <EasingDoubleKeyFrame Value="1.5" KeyTime="0:0:0.1" />
                                                    <EasingDoubleKeyFrame Value="1.1" KeyTime="0:0:0.2" />
                                                    <EasingDoubleKeyFrame Value="1.3" KeyTime="0:0:0.3" />
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[0].ScaleY">
                                                    <EasingDoubleKeyFrame Value="1.5" KeyTime="0:0:0.1" />
                                                    <EasingDoubleKeyFrame Value="1.1" KeyTime="0:0:0.2" />
                                                    <EasingDoubleKeyFrame Value="1.3" KeyTime="0:0:0.3" />
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState Name="Pressed">
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[0].ScaleX" To="0.8" Duration="0:0:0.2" DecelerationRatio="1" />
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[0].ScaleY" To="0.8" Duration="0:0:0.2" DecelerationRatio="1" />
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState Name="Disabled">
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="Opacity" To="0.5" Duration="0:0:0.2" />
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                    <VisualStateGroup Name="CheckStates">
                                        <VisualState Name="Checked">
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[1].Angle" To="3" Duration="0:0:0.2" />
                                                <ColorAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="BorderBrush.(SolidColorBrush.Color)" To="Red" Duration="0:0:0.2" />
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState Name="Unchecked">
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[1].Angle" To="0" Duration="0:0:0.2" />
                                                <ColorAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="BorderBrush.(SolidColorBrush.Color)" To="Yellow" Duration="0:0:0.2" />
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState Name="Indeterminate">
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[1].Angle" To="-8" Duration="0:0:0.2" />
                                                <ColorAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="BorderBrush.(SolidColorBrush.Color)" To="White" Duration="0:0:0.2" />
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="MinHeight" Value="50" />
                <Setter Property="FontSize" Value="25" />
                <Setter Property="FontFamily" Value="Comic Sans MS" />
            </Style>
             --------------------编程问答-------------------- <Style TargetType="TextBox">
                <Setter Property="OverridesDefaultStyle" Value="True" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="TextBox">
                            <Border BorderThickness="2" Name="BackBorder" CornerRadius="2" BorderBrush="Yellow" Background="Orange" RenderTransformOrigin="0.5,0.5">
                                <ScrollViewer Name="PART_ContentHost" />
                                <Border.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform ScaleX="1" ScaleY="1" />
                                        <RotateTransform Angle="0" />
                                    </TransformGroup>
                                </Border.RenderTransform>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup Name="CommonStates">
                                        <VisualState Name="Normal">
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[0].ScaleX" To="1" Duration="0:0:0.2" DecelerationRatio="1" />
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[0].ScaleY" To="1" Duration="0:0:0.2" DecelerationRatio="1" />
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.2" />
                                                <ColorAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="Background.(SolidColorBrush.Color)" To="Orange" Duration="0:0:0.2" />
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState Name="Disabled">
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="Opacity" To="0.5" Duration="0:0:0.2" />
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState Name="ReadOnly">
                                            <Storyboard>
                                                <ColorAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="Background.(SolidColorBrush.Color)" To="Yellow" Duration="0:0:0.2" />
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState Name="MouseOver">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[0].ScaleX">
                                                    <EasingDoubleKeyFrame Value="1.5" KeyTime="0:0:0.1" />
                                                    <EasingDoubleKeyFrame Value="1.1" KeyTime="0:0:0.2" />
                                                    <EasingDoubleKeyFrame Value="1.3" KeyTime="0:0:0.3" />
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[0].ScaleY">
                                                    <EasingDoubleKeyFrame Value="1.5" KeyTime="0:0:0.1" />
                                                    <EasingDoubleKeyFrame Value="1.1" KeyTime="0:0:0.2" />
                                                    <EasingDoubleKeyFrame Value="1.3" KeyTime="0:0:0.3" />
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                    <VisualStateGroup Name="FocusStates">
                                        <VisualState Name="Focused">
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[1].Angle" To="2" Duration="0:0:0.2" DecelerationRatio="1" />
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState Name="Unfocused">
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(TransformGroup.Children)[1].Angle" To="0" Duration="0:0:0.2" DecelerationRatio="1" />
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="MinHeight" Value="40" />
                <Setter Property="FontSize" Value="25" />
                <Setter Property="FontFamily" Value="Comic Sans MS" />
            </Style>
            <Style x:Key="SliderButtonStyle" TargetType="RepeatButton">
                <Setter Property="IsTabStop" Value="False" />
                <Setter Property="Focusable" Value="False" />
                <Setter Property="OverridesDefaultStyle" Value="True" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="RepeatButton">
                            <Border Background="Transparent" />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
             --------------------编程问答-------------------- <Style x:Key="SliderThumbStyle" TargetType="Thumb">
                <Setter Property="OverridesDefaultStyle" Value="True" />
                <Setter Property="Height" Value="30" />
                <Setter Property="Width" Value="20" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Thumb">
                            <Border Name="BackBorder" Background="Transparent" BorderBrush="Yellow" RenderTransformOrigin="0.5,0.5" BorderThickness="2" CornerRadius="5">
                                <Border.RenderTransform>
                                    <ScaleTransform ScaleX="1" ScaleY="1" />
                                </Border.RenderTransform>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup Name="CommonStates">
                                        <VisualState Name="Normal">
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.2" />
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(ScaleTransform.ScaleX)" To="1" Duration="0:0:0.2" DecelerationRatio="1" />
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(ScaleTransform.ScaleY)" To="1" Duration="0:0:0.2" DecelerationRatio="1" />
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState Name="MouseOver">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(ScaleTransform.ScaleX)">
                                                    <DoubleKeyFrameCollection>
                                                        <EasingDoubleKeyFrame Value="1.5" KeyTime="0:0:0.1" />
                                                        <EasingDoubleKeyFrame Value="1.1" KeyTime="0:0:0.2" />
                                                        <EasingDoubleKeyFrame Value="1.3" KeyTime="0:0:0.3" />
                                                    </DoubleKeyFrameCollection>
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(ScaleTransform.ScaleY)">
                                                    <DoubleKeyFrameCollection>
                                                        <EasingDoubleKeyFrame Value="1.5" KeyTime="0:0:0.1" />
                                                        <EasingDoubleKeyFrame Value="1.1" KeyTime="0:0:0.2" />
                                                        <EasingDoubleKeyFrame Value="1.3" KeyTime="0:0:0.3" />
                                                    </DoubleKeyFrameCollection>
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState Name="Pressed">
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(ScaleTransform.ScaleX)" To="0.8" Duration="0:0:0.2" DecelerationRatio="1" />
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="RenderTransform.(ScaleTransform.ScaleY)" To="0.8" Duration="0:0:0.2" DecelerationRatio="1" />
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState Name="Disabled">
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="BackBorder" Storyboard.TargetProperty="Opacity" To="0.5" Duration="0:0:0.2" />
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,