Wpf 如何在嵌套网格中设置文本块的前景?
我在Wpf 如何在嵌套网格中设置文本块的前景?,wpf,xaml,material-design-in-xaml,Wpf,Xaml,Material Design In Xaml,我在网格中有一个TextBlock,它位于popubox中,由MaterialDesignInXaml提供,一个示例结构: xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" <materialDesign:PopupBox> <Grid> <TextBlock Text="Foo" /> </Grid> </mat
网格
中有一个TextBlock
,它位于popubox
中,由MaterialDesignInXaml
提供,一个示例结构:
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
<materialDesign:PopupBox>
<Grid>
<TextBlock Text="Foo" />
</Grid>
</materialDesign:PopupBox>
但是似乎不起作用,有什么帮助吗?您需要为
网格定义一个隐式样式。试试这个:
<Style TargetType="materialDesign:PopupBox">
<Style.Resources>
<Style TargetType="Grid">
<Setter Property="TextElement.Foreground" Value="Red" />
</Style>
</Style.Resources>
</Style>
<Style TargetType="materialDesign:PopupBox">
<Style.Resources>
<Style TargetType="Grid">
<Setter Property="TextElement.Foreground" Value="Red" />
</Style>
</Style.Resources>
</Style>