繁体   English   中英

WPF将设置程序的目标名称样式化为dependencyproperty的属性

[英]WPF Styling setter's targetname to dependencyproperty's property

我试图将样式设置器的targetname设置为依赖项属性的Name属性。 不太确定该如何处理。

 //Customcontrol's Generic.xaml <Style TargetType="{x:Type Controls:MyControl}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Controls:MyControl}"> <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> <ContentControl Content="{TemplateBinding Content}"/> </Border> </ControlTemplate> </Setter.Value> </Setter> <Setter TargetName="WHAT SHOULD I PUT HERE" Property="Opacity" Value="0.75"/> </Style> // Dependency Property public static readonly DependencyProperty LabelToDisplayProperty ... // In XAML that adds the custom control LabelToDisplay="{x:Reference Name=TitleLabel}" 

基本上在TargetName我想放置LabelToDisplay属性引用的对象的name

也许您可以将不透明度设置器移动到LabelToDisplay对象中,然后仅在需要时才触发它?

也许您可以在TargetName中绑定LabelToDisplay?

如果没有,我认为有最后一个选择,您将针对LabelToDisplay进行新的DataTrigger,然后执行以下操作:

<DataTrigger.EnterActions>

    Animation here

</DataTrigger.EnterActions>

您可以轻松设置带有动画的目标。 (例如,您根本不需要“ Name”属性,只需提供所需的对象即可)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM