How to make revealPasswordButton larger? #15724
-
I accidentally tripped across the "revealPasswordButton" class for TexBox, and at just the right time--I had to add that feature to several password text boxes. And, it works great! One thing I have not been able to figure out, though, is how I can make the buttons larger. The text boxes we use have fairly large text (24 or 28 points), so I'd like to make the buttons larger as well. What is the magic incantation I can use to override the size in the Fluent styles here: Avalonia/src/Avalonia.Themes.Fluent/Controls/TextBox.xaml Lines 236 to 246 in 7278dce |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
The <Window.Styles>
<Style Selector="TextBox.revealPasswordButton[AcceptsReturn=False][IsReadOnly=False]:not(TextBox:empty)">
<Setter Property="InnerRightContent">
<Template>
<ToggleButton Theme="{StaticResource FluentTextBoxToggleButton}"
IsChecked="{Binding $parent[TextBox].RevealPassword, Mode=TwoWay}">
<Panel>
<PathIcon Data="{StaticResource PasswordBoxRevealButtonData}"
Height="36" Width="36"
IsVisible="{Binding $parent[ToggleButton].!IsChecked}"/>
<PathIcon Data="{StaticResource PasswordBoxHideButtonData}"
Height="36" Width="36"
IsVisible="{Binding $parent[ToggleButton].IsChecked}"/>
</Panel>
</ToggleButton>
</Template>
</Setter>
</Style>
</Window.Styles>
<Grid>
<TextBox
x:Name="box"
Grid.Row="1"
Classes="revealPasswordButton"
PasswordChar="*"
Text="Reveal Password" />
</Grid> If a fixed size doesn't work for you, then consider wrapping that part (using the style above) in a <ToggleButton Theme="{StaticResource FluentTextBoxToggleButton}"
IsChecked="{Binding $parent[TextBox].RevealPassword, Mode=TwoWay}">
<Viewbox>
<Grid>
<PathIcon Data="{StaticResource PasswordBoxRevealButtonData}"
Height="36" Width="36"
IsVisible="{Binding $parent[ToggleButton].!IsChecked}"/>
<PathIcon Data="{StaticResource PasswordBoxHideButtonData}"
Height="36" Width="36"
IsVisible="{Binding $parent[ToggleButton].IsChecked}"/>
</Grid>
</Viewbox>
</ToggleButton> |
Beta Was this translation helpful? Give feedback.
-
Those sizes should probably be defined as resources so they can be overridden, but there's not really any written guidance as to what should qualify. |
Beta Was this translation helpful? Give feedback.
The
PathIcon
s have their sizes set locally, so it's much easier to replace the entire style. ie.