Comments (2)
Actually the behavior of the PasswordBox is the intended behavior. Although the TextBox seems to work now, it's not intended and might break in future versions. If you try this in a UWP app, I would assume neither will work. The reason is that in hover and focused states the value of the Background
property is not used, instead TextControlBackgroundPointerOver
and TextControlBackgroundFocused
are used, respectively. To change these two brushes, you can override them like below:
<ui:SimpleStackPanel
Margin="12"
Spacing="24">
<ui:SimpleStackPanel.Resources>
<ImageBrush
x:Key="PasswordBackground"
ImageSource="/Images/login/key.png"
Stretch="None"
AlignmentY="Center"
AlignmentX="Left">
<ImageBrush.Transform>
<TranslateTransform X="10" />
</ImageBrush.Transform>
</ImageBrush>
</ui:SimpleStackPanel.Resources>
<PasswordBox
Width="200"
Padding="44,6,6,5"
HorizontalAlignment="Left"
ui:ControlHelper.PlaceholderText="Password"
Background="{StaticResource PasswordBackground}">
<PasswordBox.Resources>
<StaticResource x:Key="TextControlBackgroundPointerOver" ResourceKey="PasswordBackground" />
<StaticResource x:Key="TextControlBackgroundFocused" ResourceKey="PasswordBackground" />
</PasswordBox.Resources>
</PasswordBox>
</ui:SimpleStackPanel>
Alternatively, it might be simpler to just overlay the image on top of the control like this:
<Grid>
<PasswordBox
Width="200"
Padding="44,6,6,5"
HorizontalAlignment="Left"
ui:ControlHelper.PlaceholderText="Password" />
<Image
Source="/Images/login/key.png"
Stretch="None"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Margin="10,0,0,0"
IsHitTestVisible="False" />
</Grid>
from modernwpf.
I'm using the second way (overlay the image on top of the control) righnt now. Thanks.
from modernwpf.
Related Issues (20)
- Can you provide a compiled SampleApp application HOT 2
- Using Syncfusion and ModernWPF
- TabControl.Template Breaks Style
- How to add High contrast support to ContentDialog?
- Enter Key Not Detected in the KeyUp Event in Number Box
- Possible issue with m:DynamicColor
- Add Tabview control
- Add Aero/Acrylic/Mica effects for the window 为窗口增加Aero、云母或亚克力效果 HOT 3
- A modern-day working output of this Solution ?
- Isn't the latest version of NuGet on top?
- FontIcon 里的FontSize属性无效
- WindowsStyle = None, not working
- ResizeMode="CanMinimize" Has a bug
- Trying to build from source but getting: MSB3644 The reference assemblies for .NETFramework,Version=v4.5 were not found HOT 1
- DNS Resolution failure for schemas.modernwpf.com HOT 1
- No problem during building, but execution ModernWpf.SampleAPP failed
- Build fail
- checkbox border almost not visibile in 0.9.7 peview
- How to make DataGrid more compact HOT 1
- How to disable minimize button with "UseModernWindowStyle:true"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from modernwpf.