Skip to content

Adding win11 styles to PasswordBox #8612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 11, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVi
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.
CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.DataTrigger.Setters' changed from '[DesignerSerializationVisibilityAttribute(2)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)]' in the implementation.
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.
TypesMustExist : Type 'System.Windows.ElementPlacement' does not exist in the implementation but it does exist in the contract.
CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.EventTrigger.Actions' changed from '[DesignerSerializationVisibilityAttribute(2)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)]' in the implementation.
CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVisibilityAttribute' on 'System.Windows.FrameworkContentElement.BindingGroup' changed from '[DesignerSerializationVisibilityAttribute(0)]' in the contract to '[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]' in the implementation.
CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.FrameworkContentElement.BindingGroup' changed from '[LocalizabilityAttribute(17)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.NeverLocalize)]' in the implementation.
Expand Down Expand Up @@ -193,8 +194,20 @@ CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'S
CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.Panel' changed from '[LocalizabilityAttribute(16)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.Ignore)]' in the implementation.
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.
TypesMustExist : Type 'System.Windows.Controls.PassiveScrollViewer' does not exist in the implementation but it does exist in the contract.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
MembersMustExist : Member 'public System.Boolean System.Windows.Controls.PasswordBox.PlaceholderEnabled.get()' does not exist in the implementation but it does exist in the contract.
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.
MembersMustExist : Member 'public System.String System.Windows.Controls.PasswordBox.PlaceholderText.get()' does not exist in the implementation but it does exist in the contract.
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.
CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.RadioButton' changed from '[LocalizabilityAttribute(9)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.RadioButton)]' in the implementation.
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.
CannotChangeAttribute : Attribute 'System.Windows.LocalizabilityAttribute' on 'System.Windows.Controls.RichTextBox' changed from '[LocalizabilityAttribute(15)]' in the contract to '[LocalizabilityAttribute(LocalizationCategory.Inherit)]' in the implementation.
Expand Down Expand Up @@ -360,4 +373,4 @@ CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerSerializationVi
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.
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.
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.
Total Issues: 361
Total Issues: 374
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@
<Compile Include="System\Windows\Appearance\ThemeChangedEvent.cs" />
<Compile Include="System\Windows\Appearance\WindowBackgroundManager.cs" />
<Compile Include="System\Windows\Appearance\WindowBackdrop.cs" />
<Compile Include="System\Windows\ElementPlacement.cs" />
<Compile Include="System\Windows\Controls\FallbackBrushConverter.cs" />
<Compile Include="System\Windows\Controls\ElementPlacement.cs" />
<Compile Include="System\Windows\Controls\PassiveScrollViewer.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static PasswordBox()
PasswordCharProperty.OverrideMetadata(typeof(PasswordBox),
new FrameworkPropertyMetadata(new PropertyChangedCallback(OnPasswordCharChanged)));

// Declaree listener for Padding property
// Declare listener for Padding property
Control.PaddingProperty.OverrideMetadata(typeof(PasswordBox),
new FrameworkPropertyMetadata(new PropertyChangedCallback(OnPaddingChanged)));

Expand Down Expand Up @@ -347,6 +347,82 @@ public bool IsSelectionActive
get { return (bool)GetValue(IsSelectionActiveProperty); }
}

/// <summary>
/// Defines which side the icon should be placed on.
/// </summary>
public ElementPlacement IconPlacement
{
get => (ElementPlacement)GetValue(IconPlacementProperty);
set => SetValue(IconPlacementProperty, value);
}

/// <summary>
/// Property for <see cref="IconPlacement"/>.
/// </summary>
public static readonly DependencyProperty IconPlacementProperty = DependencyProperty.Register(
nameof(IconPlacement),
typeof(ElementPlacement),
typeof(PasswordBox),
new PropertyMetadata(ElementPlacement.Left)
);

/// <summary>
/// Gets or sets displayed <see cref="IconElement"/>.
/// </summary>
public IconElement Icon
{
get => (IconElement)GetValue(IconProperty);
set => SetValue(IconProperty, value);
}

/// <summary>
/// Property for <see cref="Icon"/>.
/// </summary>
public static readonly DependencyProperty IconProperty = DependencyProperty.Register(
nameof(Icon),
typeof(IconElement),
typeof(PasswordBox),
new PropertyMetadata(null, null, IconSourceElementConverter.ConvertToIconElement)
);

/// <summary>
/// Gets or sets numbers pattern.
/// </summary>
public string PlaceholderText
{
get => (string)GetValue(PlaceholderTextProperty);
set => SetValue(PlaceholderTextProperty, value);
}

/// <summary>
/// Property for <see cref="PlaceholderText"/>.
/// </summary>
public static readonly DependencyProperty PlaceholderTextProperty = DependencyProperty.Register(
nameof(PlaceholderText),
typeof(string),
typeof(PasswordBox),
new PropertyMetadata(String.Empty)
);

/// <summary>
/// Gets or sets a value determining whether to display the placeholder.
/// </summary>
public bool PlaceholderEnabled
{
get => (bool)GetValue(PlaceholderEnabledProperty);
set => SetValue(PlaceholderEnabledProperty, value);
}

/// <summary>
/// Property for <see cref="PlaceholderEnabled"/>.
/// </summary>
public static readonly DependencyProperty PlaceholderEnabledProperty = DependencyProperty.Register(
nameof(PlaceholderEnabled),
typeof(bool),
typeof(PasswordBox),
new PropertyMetadata(true)
);

/// <summary>
/// <see cref="TextBoxBase.IsInactiveSelectionHighlightEnabledProperty"/>
/// </summary>
Expand Down Expand Up @@ -854,7 +930,7 @@ private void Initialize()
// PasswordBox only accepts plain text, so change TextEditor's default to that.
_textEditor.AcceptsRichContent = false;

// PasswordBox does not accetps tabs.
// PasswordBox does not accepts tabs.
_textEditor.AcceptsTab = false;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace System.Windows
{
/// <summary>
/// Decides where to put the element.
/// </summary>
public enum ElementPlacement
{
/// <summary>
/// Puts the control element on the left.
/// </summary>
Left,

/// <summary>
/// Puts the control element on the right.
/// </summary>
Right
}
}
Loading