Skip to content

Commit 0759d47

Browse files
authored
Adding win11 styles to PasswordBox (#8612)
* Added TextBox styles Todo: Clear button not showing up * Added styles for PasswordBox Todo: Reveal button functionality not supported
1 parent 2c6df32 commit 0759d47

File tree

6 files changed

+399
-4
lines changed

6 files changed

+399
-4
lines changed

src/Microsoft.DotNet.Wpf/ApiCompat/Baselines/PresentationFramework-ref.baseline.txt

+14-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVi
77
CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.DataTrigger.Binding' changed from '[LocalizabilityAttribute(0, Readability=0)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)]' in the implementation.
88
CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.DataTrigger.Setters' changed from '[DesignerSerializationVisibilityAttribute(2)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)]' in the implementation.
99
CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.DataTrigger.Value' changed from '[LocalizabilityAttribute(0, Readability=0)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)]' in the implementation.
10+
TypesMustExist : Type 'System.Windows.ElementPlacement' does not exist in the implementation but it does exist in the contract.
1011
CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.EventTrigger.Actions' changed from '[DesignerSerializationVisibilityAttribute(2)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)]' in the implementation.
1112
CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.FrameworkContentElement.BindingGroup' changed from '[DesignerSerializationVisibilityAttribute(0)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]' in the implementation.
1213
CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.FrameworkContentElement.BindingGroup' changed from '[LocalizabilityAttribute(17)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.NeverLocalize)]' in the implementation.
@@ -193,8 +194,20 @@ CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'S
193194
CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.Panel' changed from '[LocalizabilityAttribute(16)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.Ignore)]' in the implementation.
194195
CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.Controls.Panel.Children' changed from '[DesignerSerializationVisibilityAttribute(2)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)]' in the implementation.
195196
TypesMustExist : Type 'System.Windows.Controls.PassiveScrollViewer' does not exist in the implementation but it does exist in the contract.
197+
MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.PasswordBox.IconPlacementProperty' does not exist in the implementation but it does exist in the contract.
198+
MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.PasswordBox.IconProperty' does not exist in the implementation but it does exist in the contract.
199+
MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.PasswordBox.PlaceholderEnabledProperty' does not exist in the implementation but it does exist in the contract.
200+
MembersMustExist : Member 'public System.Windows.DependencyProperty System.Windows.DependencyProperty System.Windows.Controls.PasswordBox.PlaceholderTextProperty' does not exist in the implementation but it does exist in the contract.
196201
CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.Controls.PasswordBox.Password' changed from '[DesignerSerializationVisibilityAttribute(0)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]' in the implementation.
197202
CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.Controls.PasswordBox.SecurePassword' changed from '[DesignerSerializationVisibilityAttribute(0)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]' in the implementation.
203+
MembersMustExist : Member 'public System.Windows.Controls.IconElement System.Windows.Controls.PasswordBox.Icon.get()' does not exist in the implementation but it does exist in the contract.
204+
MembersMustExist : Member 'public void System.Windows.Controls.PasswordBox.Icon.set(System.Windows.Controls.IconElement)' does not exist in the implementation but it does exist in the contract.
205+
MembersMustExist : Member 'public System.Windows.Controls.ElementPlacement System.Windows.Controls.PasswordBox.IconPlacement.get()' does not exist in the implementation but it does exist in the contract.
206+
MembersMustExist : Member 'public void System.Windows.Controls.PasswordBox.IconPlacement.set(System.Windows.Controls.ElementPlacement)' does not exist in the implementation but it does exist in the contract.
207+
MembersMustExist : Member 'public System.Boolean System.Windows.Controls.PasswordBox.PlaceholderEnabled.get()' does not exist in the implementation but it does exist in the contract.
208+
MembersMustExist : Member 'public void System.Windows.Controls.PasswordBox.PlaceholderEnabled.set(System.Boolean)' does not exist in the implementation but it does exist in the contract.
209+
MembersMustExist : Member 'public System.String System.Windows.Controls.PasswordBox.PlaceholderText.get()' does not exist in the implementation but it does exist in the contract.
210+
MembersMustExist : Member 'public void System.Windows.Controls.PasswordBox.PlaceholderText.set(System.String)' does not exist in the implementation but it does exist in the contract.
198211
CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.RadioButton' changed from '[LocalizabilityAttribute(9)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.RadioButton)]' in the implementation.
199212
CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.RadioButton.GroupName' changed from '[LocalizabilityAttribute(17)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.NeverLocalize)]' in the implementation.
200213
CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.RichTextBox' changed from '[LocalizabilityAttribute(15)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.Inherit)]' in the implementation.
@@ -360,4 +373,4 @@ CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVi
360373
CannotChangeAttribute : Attribute 'System.Windows.Markup.DesignerSerializationOptionsAttribute' on 'System.Windows.Markup.XmlAttributeProperties.GetXmlSpace(System.Windows.DependencyObject)' changed from '[DesignerSerializationOptionsAttribute(1)]' in the contract to '[DesignerSerializationOptionsAttribute(DesignerSerializationOptions.SerializeAsAttribute)]' in the implementation.
361374
CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.Media.Animation.Storyboard.GetTarget(System.Windows.DependencyObject)' changed from '[DesignerSerializationVisibilityAttribute(0)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]' in the implementation.
362375
CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Shapes.Shape' changed from '[LocalizabilityAttribute(0, Readability=0)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)]' in the implementation.
363-
Total Issues: 361
376+
Total Issues: 374

src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@
416416
<Compile Include="System\Windows\Appearance\ThemeChangedEvent.cs" />
417417
<Compile Include="System\Windows\Appearance\WindowBackgroundManager.cs" />
418418
<Compile Include="System\Windows\Appearance\WindowBackdrop.cs" />
419+
<Compile Include="System\Windows\ElementPlacement.cs" />
419420
<Compile Include="System\Windows\Controls\FallbackBrushConverter.cs" />
420421
<Compile Include="System\Windows\Controls\ElementPlacement.cs" />
421422
<Compile Include="System\Windows\Controls\PassiveScrollViewer.cs" />

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/PasswordBox.cs

+78-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static PasswordBox()
6363
PasswordCharProperty.OverrideMetadata(typeof(PasswordBox),
6464
new FrameworkPropertyMetadata(new PropertyChangedCallback(OnPasswordCharChanged)));
6565

66-
// Declaree listener for Padding property
66+
// Declare listener for Padding property
6767
Control.PaddingProperty.OverrideMetadata(typeof(PasswordBox),
6868
new FrameworkPropertyMetadata(new PropertyChangedCallback(OnPaddingChanged)));
6969

@@ -347,6 +347,82 @@ public bool IsSelectionActive
347347
get { return (bool)GetValue(IsSelectionActiveProperty); }
348348
}
349349

350+
/// <summary>
351+
/// Defines which side the icon should be placed on.
352+
/// </summary>
353+
public ElementPlacement IconPlacement
354+
{
355+
get => (ElementPlacement)GetValue(IconPlacementProperty);
356+
set => SetValue(IconPlacementProperty, value);
357+
}
358+
359+
/// <summary>
360+
/// Property for <see cref="IconPlacement"/>.
361+
/// </summary>
362+
public static readonly DependencyProperty IconPlacementProperty = DependencyProperty.Register(
363+
nameof(IconPlacement),
364+
typeof(ElementPlacement),
365+
typeof(PasswordBox),
366+
new PropertyMetadata(ElementPlacement.Left)
367+
);
368+
369+
/// <summary>
370+
/// Gets or sets displayed <see cref="IconElement"/>.
371+
/// </summary>
372+
public IconElement Icon
373+
{
374+
get => (IconElement)GetValue(IconProperty);
375+
set => SetValue(IconProperty, value);
376+
}
377+
378+
/// <summary>
379+
/// Property for <see cref="Icon"/>.
380+
/// </summary>
381+
public static readonly DependencyProperty IconProperty = DependencyProperty.Register(
382+
nameof(Icon),
383+
typeof(IconElement),
384+
typeof(PasswordBox),
385+
new PropertyMetadata(null, null, IconSourceElementConverter.ConvertToIconElement)
386+
);
387+
388+
/// <summary>
389+
/// Gets or sets numbers pattern.
390+
/// </summary>
391+
public string PlaceholderText
392+
{
393+
get => (string)GetValue(PlaceholderTextProperty);
394+
set => SetValue(PlaceholderTextProperty, value);
395+
}
396+
397+
/// <summary>
398+
/// Property for <see cref="PlaceholderText"/>.
399+
/// </summary>
400+
public static readonly DependencyProperty PlaceholderTextProperty = DependencyProperty.Register(
401+
nameof(PlaceholderText),
402+
typeof(string),
403+
typeof(PasswordBox),
404+
new PropertyMetadata(String.Empty)
405+
);
406+
407+
/// <summary>
408+
/// Gets or sets a value determining whether to display the placeholder.
409+
/// </summary>
410+
public bool PlaceholderEnabled
411+
{
412+
get => (bool)GetValue(PlaceholderEnabledProperty);
413+
set => SetValue(PlaceholderEnabledProperty, value);
414+
}
415+
416+
/// <summary>
417+
/// Property for <see cref="PlaceholderEnabled"/>.
418+
/// </summary>
419+
public static readonly DependencyProperty PlaceholderEnabledProperty = DependencyProperty.Register(
420+
nameof(PlaceholderEnabled),
421+
typeof(bool),
422+
typeof(PasswordBox),
423+
new PropertyMetadata(true)
424+
);
425+
350426
/// <summary>
351427
/// <see cref="TextBoxBase.IsInactiveSelectionHighlightEnabledProperty"/>
352428
/// </summary>
@@ -854,7 +930,7 @@ private void Initialize()
854930
// PasswordBox only accepts plain text, so change TextEditor's default to that.
855931
_textEditor.AcceptsRichContent = false;
856932

857-
// PasswordBox does not accetps tabs.
933+
// PasswordBox does not accepts tabs.
858934
_textEditor.AcceptsTab = false;
859935
}
860936

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace System.Windows
8+
{
9+
/// <summary>
10+
/// Decides where to put the element.
11+
/// </summary>
12+
public enum ElementPlacement
13+
{
14+
/// <summary>
15+
/// Puts the control element on the left.
16+
/// </summary>
17+
Left,
18+
19+
/// <summary>
20+
/// Puts the control element on the right.
21+
/// </summary>
22+
Right
23+
}
24+
}

0 commit comments

Comments
 (0)