のリストにバインド
<TextBlock Text="{Binding [Filters.??.Filter where name =??], UpdateSourceTrigger=PropertyChanged}"></TextBlock>
フィルターと私のTextBlockを埋めるためにしたいです
あなたはコンバータをSE:
<Page.Resources>
<Samples:FilterConverter x:Key="FilterConverter"/>
</Page.Resources>
<Grid>
<TextBox Text="{Binding Path=Filters,
Converter={StaticResource FilterConverter},
ConverterParameter=a, Mode=OneWay}"/>
</Grid>
public class ConditionalBindingVM
{
public ConditionalBindingVM()
{
Filters = new ObservableCollection<ColumnFilter>
{
new ColumnFilter {Name = "a", Filter = "filter A"},
new ColumnFilter {Name = "b", Filter = "filter B"},
new ColumnFilter {Name = "c", Filter = "filter C"},
};
}
public IEnumerable<ColumnFilter> Filters { get; private set; }
}
public class ColumnFilter
{
public string Name { get; set; }
public string Filter { get; set; }
}
public class FilterConverter : IValueConverter
{
#region Implementation of IValueConverter
public object Convert(object value, Type targetType,
object parameter, CultureInfo culture)
{
var filters = (IEnumerable<ColumnFilter>) value;
var name = (string) parameter;
var filter = filters.SingleOrDefault(f => f.Name == name);
return filter != null ? filter.Filter : string.Empty;
}
public object ConvertBack(object value, Type targetType,
object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
あなたはこの魔法の結合を行うために何を期待していますか?どのSLのバージョンを使用していますか? – Gabe
編集された質問 –