简体   繁体   中英

Hide border and textblock with a button on windows phone

I want to make border and textblock disappear when i click the button and the border and textblock appear when i click the button again.

This is my 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"/>

How to make it in windows phone 8.1?

XAML :

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

Code :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM