在 XAML 中按名称设置用户控件子项的样式?

Style usercontrol child by name in XAML?

我在Whosebug中看到了如下代码:

   <UserControl x:Class="WpfApplication3.UserControl1"
                 x:Name="Uc1"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
        <UserControl.Resources>
            <Style TargetType="Label">
                <Setter Property="Foreground"
                        Value="{Binding Foreground, ElementName=Uc1, Mode=OneWay}"/>
            </Style>
        </UserControl.Resources>

        <Grid>            
            <Label Content="Label 1"/>
            <Label Content="Label 2"/>
        </Grid>
    </UserControl>

问题: 我现在想知道是否可以在我的 usercontrol.resources 中针对特定标签进行样式设置。在我的 userControl 中有可能吗?如果是那么怎么办?

没有 Key 的样式将应用于范围内目标类型的所有实例。

给样式一个Key,喜欢,

<Style TargetType="Label" x:Key="MyLabel">

然后使用如下Key

<Label Content="Label 1" Style="{StaticResource MyLabel}" />

<!--Will not apply the style to Label 2-->
<Label Content="Label 2"/> 

编辑:

我又看了一遍你的问题,你似乎想引用 Style 中的 Target,而不是引用 Target 中的 Style。那正确吗?听起来不自然,就像想知道派生class的一个实例的名称,来自基class.