I would like to know if there is any possibility to use a property of an object bounded to the Datagrid in ConverterParameter , this is the xaml code :
<DataGrid ItemsSource="{Binding Students}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False" >
<DataGrid.Columns >
<DataGridTextColumn x:Name="Id_Column" Header="{StaticResource PersonId}"
Binding="{Binding Id}" IsReadOnly="True" FontSize="11" FontWeight="Normal" Width="Auto" MinWidth="60" />
<DataGridTextColumn x:Name="NameColumn" Header="{DynamicResource Name}" Binding="{Binding Name}" IsReadOnly="True"
FontSize="11" FontWeight="Normal" MinWidth="130" Width="*" />
<DataGridTemplateColumn x:Name="Average" Header="{DynamicResource Average}" IsReadOnly="False" Width="*" >
<DataGridTemplateColumn.CellTemplate >
<DataTemplate>
<TextBox Text="{Binding Path=AvgValue,Converter={StaticResource DoubleConverter, ConverterParameter = FailProp},Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="Auto" Height="28" IsEnabled="True" >
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
And This is the class that I'm using:
public class Student : INotifyPropertyChanged
{
private int _personId;
void OnPropertyChanged(String info)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
public int PersonId
{
get { return _personId; }
set
{
_personId= value;
OnPropertyChanged("PersonId");
}
}
// ....
private int _failprop;
public int FailProp
{
get { return _failprop; }
set
{
_failprop= value;
OnPropertyChanged("FailProp");
}
}
}
Using this code , I'm getting an exception :
'Binding' can only be set on a DependencyProperty of a DependencyObject.".
How can I fix this issue?