I wish to link the TextElement.Foreground
property of my combo box to the variable : "ALV_COULEUR"
of my object : "tValeur"
.
I note in output that it does not find variable ALV_COULEUR ...
System.Windows.Data Error: 40 : BindingExpression path error: 'ALV_COULEUR' property not found on 'object' ''Attribut' (HashCode=35307513)'. BindingExpression:Path=ALV_COULEUR; DataItem='Attribut' (HashCode=35307513); target element is 'ComboBox' (Name=''); target property is 'Foreground' (type 'Brush')
The linked object is the value and not the 'Attribut' ...
It is not possible to make a binding in this case?
Thanks!
<ComboBox IsEditable="True"
TextElement.Foreground="{Binding ALV_COULEUR, Converter={StaticResource IntToBrushConverter}, Mode=OneWay}"
ItemsSource="{Binding tValeur, Mode=OneWay}" SelectedValuePath="ALV_ID" DisplayMemberPath="ALV_VALEUR"
SelectedValue="{Binding ATT_VALEUR, Converter={StaticResource StringToIntConverter}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
IsEnabled="{Binding IsEnabled, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}">
</ComboBox>
EDIT :
my classes :
public class Attribut
{
public int ATT_ID { get; set; }
public string ATT_LIBELLE { get; set; }
public List<ValeurAttribut> tValeur { get; set; }
}
public class ValeurAttribut
{
public int ALV_ID { get; set; }
public string ALV_VALEUR { get; set; }
public int ALV_COULEUR { get; set; }
}
DataContext : DataGrid
linked to an ObservableCollection<Attribut>()