feat: WPF控件-15-ListBox2

This commit is contained in:
Bunny 2025-01-09 10:47:44 +08:00
parent c2dce1b28e
commit c9afba6819
7 changed files with 89 additions and 0 deletions

View File

@ -0,0 +1,9 @@
<Application x:Class="WPF控件_15_ListBox2.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WPF控件_15_ListBox2"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

View File

@ -0,0 +1,12 @@
using System.Configuration;
using System.Data;
using System.Windows;
namespace WPF控件_15_ListBox2;
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}

View File

@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

View File

@ -0,0 +1,14 @@
<Window x:Class="WPF控件_15_ListBox2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<ListBox Name="ListBox" SelectionChanged="ListBox_OnSelectionChanged" CheckBox.Click="ListBox_OnClick">
<CheckBox Margin="3">选项 1</CheckBox>
<CheckBox Margin="3">选项 2</CheckBox>
</ListBox>
</Grid>
</Window>

View File

@ -0,0 +1,26 @@
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}");
}
}

View File

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<RootNamespace>WPF控件_15_ListBox2</RootNamespace>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>
</Project>

View File

@ -34,6 +34,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-14-PasswordBox",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-15-ListBox", "WPF控件-15-ListBox\WPF控件-15-ListBox.csproj", "{56F8A639-E31D-49E6-BBB7-77F74BBAF66D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-15-ListBox2", "WPF控件-15-ListBox2\WPF控件-15-ListBox2.csproj", "{169AB792-6D9D-4F12-A49A-320F01A0AFF0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -108,5 +110,9 @@ Global
{56F8A639-E31D-49E6-BBB7-77F74BBAF66D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56F8A639-E31D-49E6-BBB7-77F74BBAF66D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{56F8A639-E31D-49E6-BBB7-77F74BBAF66D}.Release|Any CPU.Build.0 = Release|Any CPU
{169AB792-6D9D-4F12-A49A-320F01A0AFF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{169AB792-6D9D-4F12-A49A-320F01A0AFF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{169AB792-6D9D-4F12-A49A-320F01A0AFF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{169AB792-6D9D-4F12-A49A-320F01A0AFF0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal