I am developing silverlight web part using client object model. I have one converter in my project as follows
public class ForeGroundConverter : IValueConverter
{
public ForeGroundConverter()
{
}
public object Convert(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
//return "";
SolidColorBrush result = new SolidColorBrush(Colors.Black);
return result;
}
// No need to implement converting back on a one-way binding
public object ConvertBack(object value, Type targetType,
object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
I am using this converter to do binding for the following element
<sdk:DataGridTemplateColumn SortMemberPath="ClientName" Header="Client Name" IsReadOnly="True" >
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding ClientName}" Foreground="{Binding Foreground, Converter={StaticResource ForegroundConverter}}"></TextBlock>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
I have one property defined in TimeLog class as follows
public SolidColorBrush Foreground {get;set;}
The binding is working fine for me. Now I have a loadingrow event for datagrid as follows.
SummaryDataGrid_LoadingRow
private void SummaryDataGrid_LoadingRow(object sender, DataGridRowEventArgs e)
{
if (PaidList.Contains(timeLogObj))
{
int index = PaidList.IndexOf(timeLogObj);
PaidList[index].IsEnabled = false;
PaidList[index].CheckBoxVisibility = Visibility.Collapsed;
PaidList[index].Foreground = new SolidColorBrush(Color.FromArgb(50, 150, 150, 150));
}
}
Please see the following line in above code
PaidList[index].Foreground = new SolidColorBrush(Color.FromArgb(50, 150, 150, 150));
In the above line I want to do the binding for Foreground property of textblok dynamically for particular row index. In this case I want the converter to take the value as (return the following value for particualr row index)
new SolidColorBrush(Color.FromArgb(50, 150, 150, 150));
I am not aware how to do this. Can you please provide me any code or link for the above issue ? If I am doing anything wrong then please guide me.