C#UWP样式以编程方式更改

时间:2016-04-18 13:21:57

标签: c#

我有一个资源风格的按钮。如何在按钮内容中更改TextBlock的文本?

这是风格:

<Style x:Key="NavigationLogoutButtonStyle" TargetType="Button" BasedOn="{StaticResource NavigationBackButtonNormalStyle}">
    <Setter Property="HorizontalAlignment" Value="Stretch"/>
    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
    <Setter Property="Height" Value="48"/>
    <Setter Property="Width" Value="NaN"/>
    <Setter Property="MinWidth" Value="48"/>
    <Setter Property="AutomationProperties.Name" Value="Logout"/>
    <Setter Property="Content">
        <Setter.Value>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="48" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <FontIcon Grid.Column="0" FontSize="16" Glyph="&#xE1E0;" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                <StackPanel Grid.Column="1" Orientation="Vertical">
                    <TextBlock Style="{ThemeResource BodyTextBlockStyle}" Text="!!!TEXT HERE PROGRAMMATICALLY!!!" Foreground="{StaticResource MainColorBrush}" FontSize="13" VerticalAlignment="Center" />
                    <TextBlock Style="{ThemeResource BodyTextBlockStyle}" Text="{StaticResource LogoutButtonText}" VerticalAlignment="Center" />
                </StackPanel>
            </Grid>
        </Setter.Value>
    </Setter>
</Style>

0 个答案:

没有答案