From 2e07d45cf5fa50181a2cd451af5f75b91cade744 Mon Sep 17 00:00:00 2001 From: Tay Date: Mon, 1 Apr 2024 02:16:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- testWPFDevelopers.sln | 25 ++++++++++++ testWPFDevelopers/App.xaml | 9 +++++ testWPFDevelopers/App.xaml.cs | 14 +++++++ testWPFDevelopers/AssemblyInfo.cs | 10 +++++ testWPFDevelopers/MainViewModel.cs | 45 ++++++++++++++++++++++ testWPFDevelopers/MainWindow.xaml | 22 +++++++++++ testWPFDevelopers/MainWindow.xaml.cs | 36 +++++++++++++++++ testWPFDevelopers/testWPFDevelopers.csproj | 11 ++++++ 8 files changed, 172 insertions(+) create mode 100644 testWPFDevelopers.sln create mode 100644 testWPFDevelopers/App.xaml create mode 100644 testWPFDevelopers/App.xaml.cs create mode 100644 testWPFDevelopers/AssemblyInfo.cs create mode 100644 testWPFDevelopers/MainViewModel.cs create mode 100644 testWPFDevelopers/MainWindow.xaml create mode 100644 testWPFDevelopers/MainWindow.xaml.cs create mode 100644 testWPFDevelopers/testWPFDevelopers.csproj diff --git a/testWPFDevelopers.sln b/testWPFDevelopers.sln new file mode 100644 index 0000000..9d49047 --- /dev/null +++ b/testWPFDevelopers.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34525.116 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "testWPFDevelopers", "testWPFDevelopers\testWPFDevelopers.csproj", "{0003FC75-7BBF-4BF1-B3A6-55D2D7C792DD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0003FC75-7BBF-4BF1-B3A6-55D2D7C792DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0003FC75-7BBF-4BF1-B3A6-55D2D7C792DD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0003FC75-7BBF-4BF1-B3A6-55D2D7C792DD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0003FC75-7BBF-4BF1-B3A6-55D2D7C792DD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {78A48234-9673-425C-912D-1A983319881B} + EndGlobalSection +EndGlobal diff --git a/testWPFDevelopers/App.xaml b/testWPFDevelopers/App.xaml new file mode 100644 index 0000000..206b107 --- /dev/null +++ b/testWPFDevelopers/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/testWPFDevelopers/App.xaml.cs b/testWPFDevelopers/App.xaml.cs new file mode 100644 index 0000000..4368829 --- /dev/null +++ b/testWPFDevelopers/App.xaml.cs @@ -0,0 +1,14 @@ +using System.Configuration; +using System.Data; +using System.Windows; + +namespace testWPFDevelopers +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } + +} diff --git a/testWPFDevelopers/AssemblyInfo.cs b/testWPFDevelopers/AssemblyInfo.cs new file mode 100644 index 0000000..b0ec827 --- /dev/null +++ b/testWPFDevelopers/AssemblyInfo.cs @@ -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) +)] diff --git a/testWPFDevelopers/MainViewModel.cs b/testWPFDevelopers/MainViewModel.cs new file mode 100644 index 0000000..bcca541 --- /dev/null +++ b/testWPFDevelopers/MainViewModel.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace testWPFDevelopers +{ + public class MainViewModel + { + private ObservableCollection myVar; + + public ObservableCollection MyProperty + { + get { return myVar; } + set { myVar = value; } + } + public MainViewModel() + { + myVar = new ObservableCollection(); + myVar.Add("a001"); + myVar.Add("保001"); + myVar.Add("保德03"); + myVar.Add("dc04"); + myVar.Add("保德03"); + myVar.Add("保德03"); + myVar.Add("保德03"); + myVar.Add("保德03"); + myVar.Add("保德03"); + myVar.Add("保德03"); + myVar.Add("保德03"); + myVar.Add("保德03"); + myVar.Add("保德03"); + myVar.Add("保德03"); + myVar.Add("保德03"); + myVar.Add("保德03"); + myVar.Add("保德03"); + myVar.Add("保德03"); + myVar.Add("保德03"); + myVar.Add("保德03"); + myVar.Add("保德03"); + } + } +} diff --git a/testWPFDevelopers/MainWindow.xaml b/testWPFDevelopers/MainWindow.xaml new file mode 100644 index 0000000..e569251 --- /dev/null +++ b/testWPFDevelopers/MainWindow.xaml @@ -0,0 +1,22 @@ + + + + + diff --git a/testWPFDevelopers/MainWindow.xaml.cs b/testWPFDevelopers/MainWindow.xaml.cs new file mode 100644 index 0000000..686fda5 --- /dev/null +++ b/testWPFDevelopers/MainWindow.xaml.cs @@ -0,0 +1,36 @@ +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace testWPFDevelopers +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + List list = new List { "aa", "bb", "abc", "csd", "sdlfks", "osdi", "awd" , "aa", "bb", "abc", "csd", "sdlfks", "osdi", "awd", "aa", "bb", "abc", "csd", "sdlfks", "osdi", "awd" }; + public MainWindow() + { + InitializeComponent(); + this.DataContext=new MainViewModel(); + comboBox1.ItemsSource = list; + } + private void comboBox1_KeyUp(object sender, KeyEventArgs e) + { + + List mylist = new List(); + mylist = list.FindAll(delegate (string s) { return s.Contains(comboBox1.Text.Trim()); }); + comboBox1.ItemsSource = mylist; + comboBox1.IsDropDownOpen = true; + } + } + +} \ No newline at end of file diff --git a/testWPFDevelopers/testWPFDevelopers.csproj b/testWPFDevelopers/testWPFDevelopers.csproj new file mode 100644 index 0000000..18b9a12 --- /dev/null +++ b/testWPFDevelopers/testWPFDevelopers.csproj @@ -0,0 +1,11 @@ + + + + WinExe + net6.0-windows + enable + enable + true + + +