0
如何從取消選中複選框時返回值?我注意到你需要創建一個轉換器,但有沒有更好的方法來做到這一點?從複選框未選中事件的WPF返回值
XAML
<Grid>
<TextBox x:Name="textBox4" Visibility="Hidden" HorizontalAlignment="Left" Height="23" Margin="149,135,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="43" TextChanged="textBox4_TextChanged"/>
<CheckBox x:Name="checkBox" Content="Party?(4 or more)" HorizontalAlignment="Left" Margin="33,135,0,0" VerticalAlignment="Top" Checked="checkBox_Checked" Width="116" Height="23"/>
</Grid>
C#
private void checkBox_Checked(object sender, RoutedEventArgs e)
{
Handle(sender as CheckBox);
}
private void checkBox_Unchecked(object sender, RoutedEventArgs e)
{
Handle(sender as CheckBox);
}
void Handle(CheckBox checkBox)
{
bool chkd = checkBox.IsChecked.Value;
if (chkd)
{
textBox4.Visibility = Visibility.Visible;
textBox6.IsEnabled = IsEnabled.Equals(false);
}
else
{
textBox4.Visibility = Visibility.Hidden;
}
您使用的是MVVM嗎? –
您可以顯示您迄今爲止獲得的XAML以及您認爲與該問題相關的任何其他代碼嗎? –
@GrantWinney更新 – Wigord