WPF-Control/WPF控件-15-ListBox2/MainWindow.xaml.cs

26 lines
597 B
C#

using System.Windows;
using System.Windows.Controls;
namespace WPF控件_15_ListBox2;
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void ListBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
private void ListBox_OnClick(object sender, RoutedEventArgs e)
{
if (ListBox.SelectedItem == null) return;
Console.WriteLine($"已选中:{((CheckBox)ListBox.SelectedItem).IsChecked}");
}
}