0
我需要一些代碼的幫助少許。這個應該做的是找出用戶點擊的按鈕,然後根據用戶按下哪個按鈕來改變複選框。但是我不知道在var enabled = button.Name ==;
這一行中放入if語句的內容。按鈕點擊複選框,根據if語句結果
private void EnDis(object sender, RoutedEventArgs e)
{
var button = (Button)sender;
var enabled = button.Name == ; //confusing
var disabled = button.Name == ; //confusing
if(button.Name == "btnEnable_1")
{
chk_1.IsChecked = enabled;
chk_2.IsChecked = enabled;
chk_3.IsChecked = enabled;
chk_4.IsChecked = enabled;
}
if(button.Name == "btnDisable_1")
{
chk_1.IsChecked = disabled;
chk_2.IsChecked = disabled;
chk_3.IsChecked = disabled;
chk_4.IsChecked = disabled;
}
if(button.Name == "btnEnable_2")
{
chk_5.IsChecked = enabled;
chk_6.IsChecked = enabled;
chk_7.IsChecked = enabled;
chk_8.IsChecked = enabled;
}
}
任何幫助或指導將非常感激!
非常感謝:) – Badja