I would like to display a screen Texblock, only after pressing the button. If I do a simple code as well, the text is always displayed instead. How do I hide it? I have to work in the code behind?
<Button Content="Inizia" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="145,78,0,0" Click="Inizia"/>
<StackPanel Margin="0,155,0,0">
<ScrollViewer VerticalScrollMode="Enabled" Width="360">
<TextBlock Text="Vedo nuvole in viaggio
che hanno la forma delle cose che cambiano,
mi viene un po' di coraggio
se penso che le cose poi non rimangono mai " Height="331" Width="361" FontSize="16"/>
</ScrollViewer>
</StackPanel>
in the xaml set the Visibility
property of your Textbox
to Hidden
or Collapsed
in the buttons click event set the it to Visible
, you will need to add a Name
to the Textbox
so you can access it in the code behind
Difference between Collapsed
and Hidden
:
if you set it to Collapsed
it won't be visible and won't take any space either
if you choose for Hidden
it won't be visible but will still take in space
To do it in the xaml reference this answer on a different post
Here 'sa example on how to do it in the code behind
So Basicly You need to add a Name for Your TextBox like this:
<TextBox x:Name="MyTextbox" Visibility="Hidden" Click="button_click"/>
And then in Your eventhandler for button click event:
button_click(object sender, EventArgs e)
{
MyTextbox.Visibility = System.Windows.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.