Reputation: 123
I can't find the right syntax to bind directly the item of my list in xaml.
<Listview ItemsSource={Binding Items}>
<Listview.ItemTemplate>
<CustomUserControl Item={Binding} />
</Listview.ItemTempalte>
</Listview>
this code works fine. But when i want to add a converter to the binding, it displays me a syntax error :
<Listview ItemsSource={Binding Items}>
<Listview.ItemTemplate>
<CustomUserControl Item={Binding ,Converter={StaticResource myConverter}} />
</Listview.ItemTempalte>
</Listview>
Does anyone know the way to do it ?
Thanks!
Upvotes: 4
Views: 1932
Reputation: 123
Ok so the answer was just
{Binding Converter={StaticResource myConverter}}
without the comma..
Upvotes: 5
Reputation: 339
I think you use converter in a wrong way. You may try to define your converter as static resource.
<converters:MyConverter x:Key="myConverter" />
and use this way
<Listview ItemsSource={Binding Items}>
<Listview.ItemTemplate>
<CustomUserControl Item="{Binding, Converter={StaticResource myConverter}" />
</Listview.ItemTempalte>
or
<Listview ItemsSource={Binding Items}>
<Listview.ItemTemplate>
<CustomUserControl Item="{Binding RelativeSource={RelativeSource Self}, Converter={StaticResource myConverter}" />
</Listview.ItemTempalte>
Upvotes: 0