feat: WPF控件-14-PasswordBox
This commit is contained in:
parent
1cb02af7d1
commit
2ce4f6e245
|
@ -0,0 +1,9 @@
|
||||||
|
<Application x:Class="WPF控件_14_PasswordBox.App"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:WPF控件_14_PasswordBox"
|
||||||
|
StartupUri="MainWindow.xaml">
|
||||||
|
<Application.Resources>
|
||||||
|
|
||||||
|
</Application.Resources>
|
||||||
|
</Application>
|
|
@ -0,0 +1,12 @@
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Data;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace WPF控件_14_PasswordBox;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for App.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
}
|
|
@ -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)
|
||||||
|
)]
|
|
@ -0,0 +1,17 @@
|
||||||
|
<Window x:Class="WPF控件_14_PasswordBox.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">
|
||||||
|
<StackPanel>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<Button Margin="3" Name="ClearButton" Click="ClearButton_OnClick">清除密码</Button>
|
||||||
|
<Button Margin="3" Name="PasteButton" Click="PasteButton_OnClick">粘贴</Button>
|
||||||
|
<Button Margin="3" Name="SelectAllButton" Click="SelectAllButton_OnClick">选择全部</Button>
|
||||||
|
</StackPanel>
|
||||||
|
<PasswordBox Height="30" Name="PasswordBox" MaxLength="30" Password="这个是密码"
|
||||||
|
PasswordChanged="PasswordBox_OnPasswordChanged" />
|
||||||
|
</StackPanel>
|
||||||
|
</Window>
|
|
@ -0,0 +1,37 @@
|
||||||
|
using System.Security;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace WPF控件_14_PasswordBox;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for MainWindow.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class MainWindow : Window
|
||||||
|
{
|
||||||
|
public MainWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ClearButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
PasswordBox.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PasteButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
PasswordBox.Paste();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SelectAllButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
PasswordBox.SelectAll();
|
||||||
|
var secureString = new SecureString();
|
||||||
|
secureString.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PasswordBox_OnPasswordChanged(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(PasswordBox.Password);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
|
<RootNamespace>WPF控件_14_PasswordBox</RootNamespace>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<UseWPF>true</UseWPF>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -30,6 +30,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-12-多文本", "W
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-13-TextBox", "WPF控件-13-TextBox\WPF控件-13-TextBox.csproj", "{C53C3922-EB39-48E7-B88E-7552BDBE839D}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-13-TextBox", "WPF控件-13-TextBox\WPF控件-13-TextBox.csproj", "{C53C3922-EB39-48E7-B88E-7552BDBE839D}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-14-PasswordBox", "WPF控件-14-PasswordBox\WPF控件-14-PasswordBox.csproj", "{6371FBC1-A24A-4226-8597-357E50442F07}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -96,5 +98,9 @@ Global
|
||||||
{C53C3922-EB39-48E7-B88E-7552BDBE839D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{C53C3922-EB39-48E7-B88E-7552BDBE839D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{C53C3922-EB39-48E7-B88E-7552BDBE839D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{C53C3922-EB39-48E7-B88E-7552BDBE839D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{C53C3922-EB39-48E7-B88E-7552BDBE839D}.Release|Any CPU.Build.0 = Release|Any CPU
|
{C53C3922-EB39-48E7-B88E-7552BDBE839D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{6371FBC1-A24A-4226-8597-357E50442F07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{6371FBC1-A24A-4226-8597-357E50442F07}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{6371FBC1-A24A-4226-8597-357E50442F07}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{6371FBC1-A24A-4226-8597-357E50442F07}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
Loading…
Reference in New Issue