<TextBlock Text="{Binding Path=[0]} />
또는WPF 바인딩은
<TextBlock Text="{Binding Path=[myKey]} />
잘 작동합니다. 그러나 인덱서 키로 변수를 전달하는 방법이 있습니까?
<TextBlock Text="{Binding Path=[{Binding Column.Index}]} />
<TextBlock Text="{Binding Path=[0]} />
또는WPF 바인딩은
<TextBlock Text="{Binding Path=[myKey]} />
잘 작동합니다. 그러나 인덱서 키로 변수를 전달하는 방법이 있습니까?
<TextBlock Text="{Binding Path=[{Binding Column.Index}]} />
이는
IValueConverter
IMultiValueConverter
을 요구한다.
정말요? 당신은 값 변환기로 이것을 어떻게 할 것인지 설명 할 수 있습니까? – ColinE
아니요, 두렵습니다. 이 시점에서 데이터를 쉽게 바인딩 할 수 있도록 데이터를 형성하는 뷰 모델을 만드는 것이 좋습니다.
이 처리하는 가장 빠른 방법은 컬렉션과 바인딩에 대한 인덱스를 받아들이는 IMultiValueConverter와 MultiBinding을 사용하는 것이 있습니다 :
<TextBlock.Text>
<MultiBinding Converter="{StaticResource ListIndexToValueConverter}">
<Binding /> <!-- assuming the collection is the DataContext -->
<Binding Path="Column.Index"/>
</MultiBinding>
</TextBlock.Text>
같은 두 값을 기준으로 검색을 수행 한 후 수 변환기 이 :
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values.Length < 2)
return Binding.DoNothing;
IList list = values[0] as IList;
if (list == null || values[1] == null || !(values[1] is int))
return Binding.DoNothing;
return list[(int)values[1]];
}
미래 수색자에 대한
MSDN 링크 : http://msdn.microsoft.com/en-us/library/ms742451.aspx – yzorg
이 링크에 내 대답을 확인 http://stackoverflow.com/q/ 4385693/217880 – biju