I want to be able to convert an integer to a string using a lookup table (list) in my code.
Both the integer and the list is passed on from a COM and bound to observables in my code.
<ListView Name="IdList" MaxWidth="310" Height="190" Margin="5" SelectionMode="Single"
ItemsSource="{Binding Path=TypeItem.Ids}">'
<GridViewColumn Width="Auto"
DisplayMemberBinding="{Binding Path=ShipType,
Converter={StaticResource ShipTypeConverter},
ConverterParameter={x:Static vm:ConfigStaticItem.alternatives_shiptype}}"/>`
I have tried using multibinding, but only got DependencyProperty.UnsetValue for the list value
<GridViewColumn Width="Auto">
<GridViewColumnHeader Content="ShipType"/>
<GridViewColumn.DisplayMemberBinding >
<MultiBinding Converter="{StaticResource ShipTypeMultiConverter}">
<Binding Path="ShipType"/>
<Binding Path="ConfigStaticItem.alternatives_shiptype"/>
</MultiBinding>
</GridViewColumn.DisplayMemberBinding>
</GridViewColumn>
[ValueConversion(typeof(byte), typeof(string))]
public class ShipTypeMultiConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
try
{
byte state = (byte)values[0];
List<StaticId> list = (List<StaticId>)values[1];
return state.ToString();
}
catch
{
return "";
}
}
Also tried using templates, but I think I got lost in the XAML :).
vm is a reference to my ViewModel
the TypeItem.Ids is defined as List, where Static is an observable class containing amongst other stuff the ShipType value
Does anybody have any suggestions how to solve this?enter code here
And the solution was:
Adding a source to my resource dictionary
Using a standard binding with the static resource as converter parameter
And using a singlevalue converter