我的资源字典中有几种图像样式。正如您所看到的,对齐属性是重复的,因此我希望将这些属性转换为另一种样式,以便它们的值不会重复。有没有办法在资源字典中使用链接样式?我该怎么做?
template<class T>
class Object
{
private:
struct dummy { };
public:
Object baz(std::conditional_t<Conditional<T>::value, foo_class, dummy> param)
{ return Object(param); }
Object baz(std::conditional_t<Conditional<T>::value, dummy, void>)
{ return Object(); }
};
答案 0 :(得分:1)
当然。您可以在样式中使用继承:
<Style TargetType="Image" x:Key="common">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
<Style TargetType="Image" x:Key="Blank" BasedOn="{StaticResource common}">
<Setter Property="Source" Value="/images/blank.png"/>
</Style>
<Style TargetType="Image" x:Key="BlockArrowLeft" BasedOn="{StaticResource common}">
<Setter Property="Source" Value="/images/block_arrow_left.png"/>
</Style>
或者:
<Style TargetType="Image">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
<Style TargetType="Image" x:Key="Blank" BasedOn="{StaticResource {x:Type Image}}">
<Setter Property="Source" Value="/images/blank.png"/>
</Style>
<Style TargetType="Image" x:Key="BlockArrowLeft" BasedOn="{StaticResource {x:Type Image}}">
<Setter Property="Source" Value="/images/block_arrow_left.png"/>
</Style>