2012-09-07 69 views
0

我试图将样式设置器的targetname设置为依赖属性的Name属性。不太确定如何解决这个问题。WPF样式设置者的目标名称为dependencyproperty的属性

//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我希望把对象的nameLabelToDisplay属性引用。

回答

0

也许你可以将该不透明度设置器移动到LabelToDisplay对象中并仅在需要时触发它?

也许你可以绑定在TargetName中的LabelToDisplay?

如果不是,还有最后一个选择,我认为,你会做出对LabelToDisplay新DataTrigger,然后你做:

<DataTrigger.EnterActions> 

    Animation here 

</DataTrigger.EnterActions> 

您可以通过动画轻松设定目标。 (例如,根本不需要“名称”属性,只需给它所需的对象)

相关问题