I am trying to bind a collection of object to Listbox which has a Item template defined for radio button. In the radio button for IsChecked property i need the reference of the item source object that it is bind to..
Sample Xmal:
<ListView ItemsSource="{Binding Path=Ports}">
<ListView.ItemTemplate>
<DataTemplate>
<RadioButton Grid.Row="0" IsChecked="{Binding Path=Port, Converter={StaticResource PortConverter}, ConverterParameter=ABC, UpdateSourceTrigger=PropertyChanged}">ABC</RadioButton>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Sample Object:
public class Port {
public string Name {get; set;}
}
View Model:
public IEnumerable< Port > Ports {get; set;}
Need some pointers to the same..
Just remove the path from your bindings or give path as dot(.), it should work. I am assuming that code in your converter takes an object of type Port and based on some conditions you are returning bool value from there since Port is an object of a class and not a bool value.
<RadioButton Grid.Row="0" IsChecked="{Binding Path=., Converter={StaticResource PortConverter}, ConverterParameter=ABC, UpdateSourceTrigger=PropertyChanged}">ABC</RadioButton>