我正在尝试将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
我想把name
那个LabelToDisplay
属性引用的对象的。