开发者

Can I use an IConverter on a ListBoxItem whose parent ListBox.ItemsSource is bound to a list<int>

开发者 https://www.devze.com 2023-03-11 10:00 出处:网络
I don\'t know how to bind to an int since it has no properties. <ListBox Name=\"AgencyTypeListBox\">

I don't know how to bind to an int since it has no properties.

<ListBox Name="AgencyTypeListBox"  >
 <ListBox.ItemTemplate >
  <DataTemplate>
   <TextBlock Text="{Binding Path=whatDoIPutHere, Converter={BLL:CodeMarkupExtension}}" />
  </DataTemplate>
 </ListBox.ItemTemplate>开发者_如何学运维
</ListBox>

In my code behind I do this

AgencyTypeListBox.ItemsSource = (List<int>) someListofInts; 


If the ItemsSource is a list of ints, the data context of each item will already be an integer list entry; you don't need to specify any path.

<TextBlock Text="{Binding Converter={BLL:CodeMarkupExtension}}" />
0

精彩评论

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