This is a migrated thread and some comments may be shown as answers.

IDE error when binding on SelectedItem

1 Answer 80 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Boardy
Top achievements
Rank 1
Veteran
Boardy asked on 15 Feb 2018, 10:27 AM

In my application I bind the value of a textbox to properties of the selected item of a grid.

When do something like (note: grdParts is defined elsewhere and has the default SelectionUnit = FullRow)

<TextBox Text="{Binding ElementName=grdParts, Path=SelectedItem.OrderCode}" />

the error list shows the error 'SelectedItem' is not accessible. But the application compiles fine and works as intended. My biggest problem is that these 'fake' errors obscure real problems.

A while ago I tackled this problem by adding the ElementName in the Path, but recently (because I updated to the newest Telerik version?) this stopped working, so I had to revert back to this way of binding.

What is wrong with this binding?

1 Answer, 1 is accepted

Sort by
0
Boardy
Top achievements
Rank 1
Veteran
answered on 15 Feb 2018, 11:03 AM

Never mind. After some more researching and trials, it seems that the following works:

Add the Telerik controls assembly

<Window ...
   xmlns:tdc="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Data" >

 

And change the binding to

<TextBox Text="{Binding ElementName=grdParts, Path=(tdc:DataControl.SelectedItem).OrderCode}" />

to define where the SelectedItem property can be found.

Tags
GridView
Asked by
Boardy
Top achievements
Rank 1
Veteran
Answers by
Boardy
Top achievements
Rank 1
Veteran
Share this question
or