相关疑难解决方法(0)

XAML组合样式

我对此并不是很有希望,但有没有办法在XAML中组合多种样式来制作具有所有所需设置的新样式?

例如(伪代码);

<Style x:key="A">
 ...
</Style>

<Style x:key="B">
 ...
</Style>

<Style x:key="Combined">
 <IncludeStyle Name="A"/>
 <IncludeStyle Name="B"/>
 ... other properties.
</Style>
Run Code Online (Sandbox Code Playgroud)

我知道样式有一个'BasedOn'属性,但是这个功能只会带你到目前为止.我真的只是在寻找一种简单的方法(在XAML中)来创建这些"组合"样式.但就像我之前说过的那样,我怀疑它是否存在,除非有人听说过这样的事情?

wpf xaml styles

43
推荐指数
1
解决办法
2万
查看次数

如何为一个控件定义多种样式?

我正在尝试在一个按钮中设置多种样式,特别是我:

风格 (1) =>Style="{StaticResource VisibleAnimation}"
风格 (2) =>Style="{DynamicResource AccentedSquareButtonStyle}"

一个伪代码:

<Button Content="Invia" Style="{DynamicResource AccentedSquareButtonStyle, VisibleAnimation}" ></Button>
Run Code Online (Sandbox Code Playgroud)

编辑:合并的可能解决方案

<Style TargetType="FrameworkElement" x:Key="VisibleAnimation" BasedOn="{DynamicResource AccentedSquareButtonStyle}">
Run Code Online (Sandbox Code Playgroud)

编译器在 BaseOn 行下划线并显示我:

无法根据类型样式设置 DynamicResourceExtension 的属性。您只能为 DependencyObject 的依赖属性设置 DynamicResourceExtension。

我怎么能做到这一点?

wpf xaml

3
推荐指数
1
解决办法
3689
查看次数

标签 统计

wpf ×2

xaml ×2

styles ×1