Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug DependencyProperty.Unsetvalue errors when the InnerException is null

I have a custom login usercontrol that has a normal textbox and a passwordbox.

Blend refuses to cooperate with the PasswordBox saying that "DP.UnsetValue" is not valid for PasswordChar property. However the project compiles and runs fine in Blend or in VS2010. The cider designer in VS2010 doesn't seem to mind the error because it actually renders my UserControl for design time configuration.

Normally when I get one of these errors there is an InnerException with a path to the file/resource missing. That's not the case here and I'm not sure how to figure out how to fix it for when this comes up in the future.

I swapped the tags to turn the PasswordBox into a normal TextBox and it seems to be fine with that. However I need the input masking that PasswordBox provides. It's not very practical to comment out that object and finish styling my control in Blend.

Here's my Xaml:

 <PasswordBox x:Name="PasswordTextbox" PasswordChar="*" Height="26" VerticalAlignment="Center" Grid.Column="1" Grid.Row="1" Margin="5" RenderTransformOrigin="0.5,0.5" TabIndex="3">
                <PasswordBox.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform/>
                    </TransformGroup>
                </PasswordBox.RenderTransform>
                <PasswordBox.Effect>
                    <DropShadowEffect />
                </PasswordBox.Effect>
                <PasswordBox.Triggers>
                    <EventTrigger RoutedEvent="UIElement.GotFocus">
                        <BeginStoryboard Storyboard="{StaticResource StoryboardScaleUpFontIncrease}"/>
                    </EventTrigger>
                    <EventTrigger RoutedEvent="UIElement.LostFocus">
                        <BeginStoryboard Storyboard="{DynamicResource StoryboardScaleNormalFontNormal}"/>
                    </EventTrigger>
                </PasswordBox.Triggers>
            </PasswordBox>

Does anyone know how to debug this behavior?

like image 444
TWood Avatar asked Sep 24 '10 19:09

TWood


1 Answers

I also had the same issue in xaml designer but in a sightly different way. I add the detail here in case it is helpful to someone.

I was using a 3rd party control which has their own theme defined in a dll. I referenced this dll and use 'StaticResource' to reference some resources defined in that dll. Then the xaml designer underlined my xaml code saying something like 'D.Unset is not a valid value for xxx'. But the program compile and run without any problem.

To eliminate these annoying underline, the solution is simple: Change 'StaticResource' to 'DynamicResource'. Another more complicated way is to use 'ResourceDictionary.MergedDictionaries' to include resources in that dll into your xaml file.

like image 171
Anstinus Avatar answered Oct 07 '22 10:10

Anstinus