使用Windows手机上的按钮隐藏边框和文本块

时间:2015-01-06 05:13:44

标签: c# xaml windows-phone-8.1

我想在单击按钮时使边框和文本块消失,再次单击按钮时会出现边框和文本块。

这是我的xaml:

<Border x:Name="descbox" Background="#A6CFC9A8" Height="80" VerticalAlignment="Bottom" Visibility="Visible" Margin="0,-100,0,0">
    <ScrollViewer VerticalScrollMode="Auto" Height="auto" Margin="0,0,0.333,0" HorizontalScrollBarVisibility="Visible">
        <StackPanel Width="548">
            <TextBlock x:Name="desc" Text="{Binding Description}" FontFamily="verdana" FontSize="19" Foreground="#CC000000" TextWrapping="Wrap" Padding="0,10" TextAlignment="Justify" Margin="0,0,10.333,0"/>
        </StackPanel>
    </ScrollViewer>
</Border>

<Button Content="Button"/>

如何在Windows Phone 8.1中制作?

1 个答案:

答案 0 :(得分:0)

XAML:

<Button Content="Button" Click="Button_Click"/>

代码:

private void Button_Click(object sender, RoutedEventArgs e)
{
    if (descbox.Visibility == Visibility.Visible)
        descbox.Visibility = Visibility.Collapsed;
    else
        descbox.Visibility = Visibility.Visible;
}