当我使用XAML时,它是否继承了像color这样的属性?(When I am using XAML does it inherit properties like color?)
如果我有这个代码:
<Grid Margin="10"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <local:HOV Grid.Row="0" /> <local:HST Grid.Row="1" /> <local:HAC Grid.Row="2" /> <local:HAI Grid.Row="3" /> </Grid>我想在网格内的所有内容中设置文本的颜色我可以指定:
TextColor="Gray"在然后里面的一切都会有灰色?
If I have this code:
<Grid Margin="10"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <local:HOV Grid.Row="0" /> <local:HST Grid.Row="1" /> <local:HAC Grid.Row="2" /> <local:HAI Grid.Row="3" /> </Grid>and I want to set the color of the text in everything inside the grid can I just specify:
TextColor="Gray"in the and then everything inside there will be Gray color?
最满意答案
Grid不支持TextColor属性。 您可以使用隐式样式并为内容页面上的所有标签着色,如下所示:
<ContentPage.Resources> <Style TargetType="Label"> <Setter Property="TextColor" Value="Gray"></Setter> </Style> </ContentPage.Resources>您可以创建这样的命名样式:
<ContentPage.Resources> <Style x:Key="lblStyle" TargetType="Label"> <Setter Property="TextColor" Value="Red"></Setter> </Style> </ContentPage.Resources>并将其应用于这样的标签:
<Label Style="{StaticResource lblStyle}" Text="Test" Grid.Row="0" />Grid doesn't support the TextColor property. You can use an implicit style and color all the labels on a content page like this:
<ContentPage.Resources> <Style TargetType="Label"> <Setter Property="TextColor" Value="Gray"></Setter> </Style> </ContentPage.Resources>You can create a named style like this:
<ContentPage.Resources> <Style x:Key="lblStyle" TargetType="Label"> <Setter Property="TextColor" Value="Red"></Setter> </Style> </ContentPage.Resources>And apply it to a label like this:
<Label Style="{StaticResource lblStyle}" Text="Test" Grid.Row="0" />更多推荐
发布评论