Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/157.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
类WPF的Silverlight继承_Wpf_Silverlight_Expression Blend_Silverlight 5.0 - Fatal编程技术网

类WPF的Silverlight继承

类WPF的Silverlight继承,wpf,silverlight,expression-blend,silverlight-5.0,Wpf,Silverlight,Expression Blend,Silverlight 5.0,要最小化WPF中的代码行,“我的所有控件”都继承自一个名为BaseControlStyle的样式,该样式如下所示: <Style x:Key="BaseControlStyle" TargetType="{x:Type FrameworkElement}"> <Setter Property="FocusVisualStyle" Value="{x:Null}"/> <Setter Property="SnapsToDevicePixels" Val

要最小化WPF中的代码行,“我的所有控件”都继承自一个名为BaseControlStyle的样式,该样式如下所示:

<Style x:Key="BaseControlStyle" TargetType="{x:Type FrameworkElement}">
    <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
    <Setter Property="SnapsToDevicePixels" Value="True"/>
    <Style.Triggers>
        <Trigger Property="IsEnabled" Value="false">
            <Setter Property="Opacity" Value="0.5"/>
        </Trigger>
    </Style.Triggers>
</Style>
<Style x:Key="ButtonStyle" TargetType={x:Type Button} BasedOn="{StaticResource BaseControlStyle}">
....
</Style>

新按钮样式如下所示:

<Style x:Key="BaseControlStyle" TargetType="{x:Type FrameworkElement}">
    <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
    <Setter Property="SnapsToDevicePixels" Value="True"/>
    <Style.Triggers>
        <Trigger Property="IsEnabled" Value="false">
            <Setter Property="Opacity" Value="0.5"/>
        </Trigger>
    </Style.Triggers>
</Style>
<Style x:Key="ButtonStyle" TargetType={x:Type Button} BasedOn="{StaticResource BaseControlStyle}">
....
</Style>

....

但是作为Silverlight的新手,我找不到一个答案:是否可以将此BaseControlStyle转换为使用VisualStateManager(或其他)的SilverlightBaseControlStyle?

不幸的是,Silverlight中没有属性触发器,而是使用可视状态,这意味着在代码中处理外观。对于像您这样的任务,更容易创建标准按钮样式的副本并在其默认控件模板中更改动画。
有时它也很有用。

不幸的是,silverlight不支持这种类型的使用:

BasedOn="{StaticResource {x:Type Button}}"

谢谢你的快速回答。我自己也做了一些研究,没有找到其他答案。所以不幸的是,似乎没有比复制控件模板更好的方法了。但我肯定在考虑用行为来处理更复杂的事情。再次感谢;)是的,有时候行为真的很有帮助!欢迎:)