Reputation: 9991
I am using MVVP pattern to share most of the code between Windows Store (aka Metro) and WPF applications. One of the controls has its visibility controlled by state of a view model member:
Visibility="{Binding Path=IsServiceSelected,
Mode=TwoWay,
Converter={StaticResource BoolToVisibility}}"
A property "IsServiceSelected" is defined on a view model behind the data context. I have a fake view model with some data only used by the designer. The property IsServiceSelected in this fake model is evaludated to "true" (there is no member field for this property, it's computed based on other data). This works fine for a WPF application, I see that the control's visibility is Visible. But for the Windows Store app the control's visibility is always Collapsed at design-time, only at runtime it's evaluated correctly.
If I extend XAML definition with ConverterParameter=True, the control shows up, so it's obviously the value of "IsServiceSelected" that is not evaluated correctly. But what is strange is that I share the same code (in a portable class library) for my models, view models and that particular fake view model, so it should be evaluated to the same value on different platforms. But it does not.
UPDATE False alarm, the problem was with my code. Fixed.
Upvotes: 0
Views: 265
Reputation: 17865
Different behavior is probably caused by the converter, since setting ConverterParameter=True
makes it work in Windows Store apps as well. You obviously can't be using the same the same converter both in WPF and Windows Store apps since they have to implement a different interface.
Compare both implementations and you should be able to spot the difference. For Windows Store apps implementation in particular check how parameter
argument of Convert
method is used. Setting it to true
seems to change the return value.
Upvotes: 1