skip to Main Content

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

  1. Why is it looking for a Text property, Password Box does not have this property!?
  2. It fails even if I add a Text entry in the resources file as shown. Why?
  3. What is the root cause of this error, and the fix?

2

Answers


  1. Chosen as BEST ANSWER

    Finally fixed this issue, but the scenario is important:

    1. The original definition was a TextBox, which I then changed to PasswordBox
    2. This is when Visual Studio (VS) was still looking to resolve a Text property (of the TextBox I assume vs the PasswordBox.Content property), therefore I thought there must be some caching going on.
    3. I tried to do the Build/Clean Solution thing, with no success
    4. I then did #3 again, restarted VS, still no success
    5. I then did #3 again, changed the name of the db_pwd resources and reference to db_pswd, deleted db_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 to HyperlinkButton. Fixed through a similar process (step #5)!


  2. To answer your questions:

    1.Why is it looking for a Text property, Password Box does not have this property!?
    2.It fails even if I add a Text entry in the resources file as shown. Why?

    The PasswordBox control doesn’t have a Text property. It has a Password property.

    3.What is the root cause of this error, and the fix?

    To fix this error you need to change your resource:

    db_pwd.Text -> db_pwd.Password

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search