ユーザーが 'whatsYourNameTextbox'に自分の名前を入力してEnterキーを押すと、非表示のテキストブロック( 'doYouWannaPlayTextblock')をVisibleにします。私は、Windowsフォームで作業するには、以下のしまったテキストボックスにテキストを入力してEnterキーを押したときに、テキストブロックの可視性を「可視」にするにはどうすればよいですか?
<TextBox x:Name="playerNameTextbox"
Grid.Column="1" Grid.Row="2"
VerticalAlignment="Top"
HorizontalAlignment="Center"
BorderBrush="Black"
Height="auto"
Width="160"
HorizontalContentAlignment="Center"
CaretBrush="red"
FontFamily="Segoe Print"
FontSize="30"
ToolTip="Type your name and then press Enter"
KeyUp="playerNameTextbox_KeyUp" />
<TextBlock Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2"
x:Name="doYouWannaPlayTextblock"
FontFamily="Segoe Print"
FontSize="16"
FontWeight="SemiBold"
Foreground="Red"
Padding="20"
Visibility="Hidden"
TextAlignment="Center"
TextWrapping="Wrap" Margin="0,0.4,0.2,-25">
Hi,
<TextBlock Text="{Binding Path=Text, ElementName=playerNameTextbox}"/>
- it's good to see you. Would you like to play 'Tables'? If so, just click the 'Choose Game' button.
</TextBlock>
:
private void playerOneNameTextbox_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
doYouWantToPlayTextbox.Visible = true;
doYouWantToPlayTextbox.Text = "Hi, " + playerOneNameTextbox.Text + ". " +
"It's good to see you! " +
"\r\nWould you like to play with us? " +
"\r\nIf you would, just click right here in this box.";
clickToPlayTimer.Start();
}
が、私はコードビハインドでWPFに私ができることを使用trytoとき、これは私がXAMLでこれまで持っているものです「Tは、次を超えて取得する:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void playerNameTextbox_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
doYouWannaPlayTextblock.Visibility = Visible;
}
}
}
}
'' 目に見える、と私が試した他のすべて、赤squiを投げますggly。
ご協力いただければ幸いです。
です。Kemalのおかげで、これは完璧に機能しました。 – Mike
あなたは歓迎です:) @Mike –