クライアントオブジェクトモデルを使用してSilverlight Webパーツを開発しています。コンバータを使用する要素の動的バインディングを行う方法は?
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();
}
}
を次のように私は私のプロジェクト内の1つのコンバータを持って、私は次の要素
<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>
の結合を行うためにこのコンバーターを使用しています
public SolidColorBrush Foreground {get;set;}
を次のように私はTimeLogクラスで定義されたプロパティを1つ持っています
バインディングがうまく動作しています。今私は、次のようにDataGridのローディングイベントを持っています。
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));
}
}
私は特定の行インデックスのための動的textblokのForegroundプロパティのバインディングを実行したい上記の行では、上記のコード
PaidList[index].Foreground = new SolidColorBrush(Color.FromArgb(50, 150, 150, 150));
に次の行を参照してください。この場合、私はこれを行う方法を知りません
new SolidColorBrush(Color.FromArgb(50, 150, 150, 150));
(particualr行インデックスに次の値を返す)とコンバータが値を取りたいです。上記の問題のコードやリンクを教えてください。私が何か悪いことをしているなら、私を案内してください。
私はあなたのビジネスオブジェクトに固執し、行インデックスを使用しないことをお勧めします。そのインデックスを保持し、それにバインドできるオブジェクトプロパティの1つにすることはできますか? –