开发者

Xaml: Itemssource binding + fallbackValue

开发者 https://www.devze.com 2023-04-02 20:59 出处:网络
I\'ve got a Listpicker with a DataBinding on the Itemssource-Property. Binding works fine. Now I want to define a FallbackValue. My problem is, that the FallbackValue is interpreted as a list: {\'S\',

I've got a Listpicker with a DataBinding on the Itemssource-Property. Binding works fine. Now I want to define a FallbackValue. My problem is, that the FallbackValue is interpreted as a list: {'S','t','a','n','d',开发者_JAVA技巧'a','r','d'}, not as a single item 'Standard'. I'm looking for a solution to solve this problem. Any idea?

<toolkit:ListPicker x:Name="listPicker" ExpansionMode="FullScreenOnly" ItemsSource="{Binding Profilelist, ElementName=userControl, FallbackValue='Standard'}" SelectedIndex="0" />


The fallback behaviour is correct as the target expects an array (and a string an usable as an array of chars). There is no easy way to specify an array for the fallback.

I would suggest binding to a ViewModel list, instead of directly to the other control, so you can specify whatever default you want in the list. It does mean an extra binding and a property on your ViewModel (or code-behind... yuk) but element binding is not designed to have a fallback array, only single values.

If you can provide more code/Xaml I will be able to be more specific.

0

精彩评论

暂无评论...
验证码 换一张
取 消