Boolean to Visibility Converter in Win RT XAML not

2019-07-17 03:20发布

问题:

Strange one when working in XAML for Windows RT (windows store app) today, when IsValid=true is set from my view model my boolean to visibility converter does not work the first time (my path remains hidden), but then does display correctly visibility subsequent times after that.

Is this a bug, or what could be going on?

I want to show my tick on IsValid=true including initial time:

<Path x:Name="MyTick" Data="F1 M 45.12,5.49L 21.255,40.8L 20.4525,40.8L 0,23.2875L 5.775,15.7875L 19.2525,27.3L 37.695,-1.90735e-006L 45.12,5.49 Z " 
Fill="#FF008500" Grid.Column="1" Width="42" Height="42" Margin="24,12,12,0" 
Stretch="Fill" VerticalAlignment="Top"  Visibility="{Binding IsValid, Converter={StaticResource BooleanToVisibilityConverter}}" />

resorting to setting the visibility on code behind of the .xaml.cs does work, but this defeats the purpose of MVVM for such a simple operation and I'd prefer not to do it this way.

This problem also occurs on first time of a textblock I need to show/hide on IsValid=true also. First time, it still is collapsed, second time I raise the property changed, it works fine. :S

回答1:

Nevermind... It was my own stupid fault, it seems I had another condition in the getter of the IsValid property which was always false when it shouldn't have been.

Fixed :)