开发者

WPF DataBinding specifying array index in Binding not working

开发者 https://www.devze.com 2023-01-19 23:01 出处:网络
I am facing a problem with DataBinding in WPF:::: The below code is working: <TextBox Text=\"{Binding ProcessStepBlock.ProcessStep[2].ProcessDescription}\"></TextBox>

I am facing a problem with DataBinding in WPF::::

The below code is working:

<TextBox Text="{Binding ProcessStepBlock.ProcessStep[2].ProcessDescription}"></TextBox>
 <TextBox Text="{Binding ProcessStepBlock.SelectedIndex}" ></TextBox>

The below code is not work开发者_StackOverflowing:It gives me a binding error BindingExpression path error: '[ ]' property not found on 'object' ''ObservableCollectionEx`1'

 <TextBox Text="{Binding ProcessStepBlock.ProcessStep[ProcessStepBlock.SelectedIndex].ProcessDescription}"></TextBox>
 <TextBox Text="{Binding ProcessStepBlock.SelectedIndex}" ></TextBox>

Please help!!!


The XAML parser can't resolve properties to provide values inside a PropertyPath. To get what you're looking for use a MultiBinding that takes both the ProcessStep collection and the SelectedIndex property and create an IMultiValueConverter that produces the ProcessDescription by doing the indexing in code.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号