Skip to content
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

add "PasswordBox" support "ButtonsAlignment" #3074

Merged
merged 1 commit into from
Oct 9, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/MahApps.Metro/MahApps.Metro/Styles/Controls.PasswordBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<Grid x:Name="PART_InnerGrid" Margin="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong value if buttons alignment is right.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a new style?

<ColumnDefinition Width="Auto" />
<ColumnDefinition x:Name="ButtonColumn" Width="Auto" />
</Grid.ColumnDefinitions>
Expand Down Expand Up @@ -450,6 +450,13 @@
Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.DisabledVisualElementVisibility), Mode=OneWay}" />
</Grid>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=(Controls:TextBoxHelper.ButtonsAlignment)}" Value="Left">
<Setter TargetName="ButtonColumn" Property="Width" Value="*" />
<Setter TargetName="PART_ClearText" Property="Grid.Column" Value="0" />
<Setter TargetName="PART_ContentHost" Property="Grid.Column" Value="1" />
<Setter TargetName="PART_Message" Property="Grid.Column" Value="1" />
</DataTrigger>

<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Password, Mode=OneWay}" Value="">
<Setter TargetName="PART_Message" Property="Visibility" Value="Visible" />
</DataTrigger>
Expand All @@ -468,6 +475,15 @@
</MultiDataTrigger.ExitActions>
</MultiDataTrigger>

<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(Controls:TextBoxHelper.ButtonsAlignment)}" Value="Right" />
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(Controls:TextBoxHelper.TextButton)}" Value="False" />
</MultiDataTrigger.Conditions>
<Setter TargetName="PART_ContentHost" Property="Grid.ColumnSpan" Value="2" />
<Setter TargetName="PART_Message" Property="Grid.ColumnSpan" Value="2" />
</MultiDataTrigger>

<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Base" Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.MouseOverBorderBrush)}" />
</Trigger>
Expand Down