I am trying to define a setting page that includes a PasswordBox element. When I Rebuild the app, the defined Text resources do not show properly. However, if I remove the:
x:Uid="/resources/db_pwd"
definition (see below) then it Rebuilds the view OK. If I try to initialize the view with the resource link defined then I get the error below. It appears as if a Text property for the PasswordBox … but it does not have this property. Very confused!
Resources
|Name | Value |
|-----------------------|---------------------------|
|db_pwd.Header |Password (default password)|
|db_pwd.PlaceholderText |Enter your password |
|db_pwd.Text |Password (default pwd) |
Password Box
<PasswordBox x:Name="dbpwd" Width="300" x:Uid="/resources/db_pwd"
Header="Database Password"
PlaceholderText="Enter password"
PasswordChanged="PasswordBox_PasswordChanged"
HorizontalAlignment="Left" Margin="40,5,0,0" />
Error Initializing View
Windows.UI.Xaml.Markup.XamlParseException
HResult=0x802B000A
Message=The text associated with this error code could not be found.
Unable to resolve property 'Text' while processing properties for Uid '/sql/db_pwd'. [Line: 38 Position: 68]
Source=Windows
StackTrace:
at Windows.UI.Xaml.Application.LoadComponent(Object component, Uri resourceLocator, ComponentResourceLocation componentResourceLocation)
at WeeWX.Views.SettingsPage.InitializeComponent() in D:DaveDocumentsVisual StudioWeeWXobjx86DebugViewsSettingsPage.g.i.cs:line 49
at WeeWX.Views.SettingsPage..ctor() in D:DaveDocumentsVisual StudioWeeWXViewsSettingsPage.xaml.cs:line 49
at WeeWX.Views.MainPage.SetSettings(Object sender, TappedRoutedEventArgs e) in D:DaveDocumentsVisual StudioWeeWXViewsMainPage.xaml.cs:line 350
This exception was originally thrown at this call stack:
[External Code]
WeeWX.Views.SettingsPage.SettingsPage() in SettingsPage.xaml.cs
WeeWX.Views.MainPage.SetSettings(object, Windows.UI.Xaml.Input.TappedRoutedEventArgs) in MainPage.xaml.cs
Questions
- Why is it looking for a Text property, Password Box does not have this property!?
- It fails even if I add a Text entry in the resources file as shown. Why?
- What is the root cause of this error, and the fix?
2
Answers
Finally fixed this issue, but the scenario is important:
TextBox
, which I then changed toPasswordBox
Text
property (of theTextBox
I assume vs thePasswordBox.Content
property), therefore I thought there must be some caching going on.db_pwd
resources and reference todb_pswd
, deleteddb_pwd.Text
, rebuilt the solution and ... success!Not sure exactly what steps are required to fix this sort of issue, but the bottom line is that VS has some really dumb (overly optimistic) caching going on! Comments or advice?
PS: Now have a similar issue after changing a
TextBox
toHyperlinkButton
. Fixed through a similar process (step #5)!To answer your questions:
The
PasswordBox
control doesn’t have aText
property. It has aPassword
property.To fix this error you need to change your resource:
db_pwd.Text
->db_pwd.Password