Boolean to Visibility Converter in Win RT XAML not working first time

你离开我真会死。 提交于 2019-12-12 16:42:51

问题


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 :)



来源:https://stackoverflow.com/questions/12988532/boolean-to-visibility-converter-in-win-rt-xaml-not-working-first-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!