如何在嵌套网格中设置TextBlock的前景?

时间:2018-02-07 11:30:28

标签: wpf xaml material-design-in-xaml

TextBlock内的Grid位于PopupBox MaterialDesignInXaml内,xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" <materialDesign:PopupBox> <Grid> <TextBlock Text="Foo" /> </Grid> </materialDesign:PopupBox> 示例结构:

TextBlock

我尝试将App.xaml前景作为全局资源应用于 <Style TargetType="materialDesign:PopupBox"> <Setter Property="TextBlock.Foreground" Value="red" /> </Style>

tslint.config

但似乎没有工作,有什么帮助吗?

1 个答案:

答案 0 :(得分:0)

您需要为Style定义隐式Grid。试试这个:

<Style TargetType="materialDesign:PopupBox">
    <Style.Resources>
        <Style TargetType="Grid">
            <Setter Property="TextElement.Foreground" Value="Red" />
        </Style>
    </Style.Resources>
</Style>