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

Selected Value is always null (Items Source is bound to XmlDataProvider)

3 Answers 153 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Igor Stefanovic
Top achievements
Rank 1
Igor Stefanovic asked on 07 Feb 2017, 10:08 AM

I have simple xml bound to RadListBox using XmlDataProvider. Xml is simple and it looks like this:

<Views><br>  <View Caption="PARTIES" Path="/Views/PartyView.xaml" /><br>  <View Caption="CANDIDATES" Path="/Views/CandidateView.xaml" /><br>  <View Caption="CANDIDATE POSITIONS" Path="/Views/CandidatePositionView.xaml" /><br>  <View Caption="ELECTION" Path="/Views/ElectionView.xaml" /><br></Views>

Provider is set like this:

<XmlDataProvider x:Key="xdpViews" Source="/Menu/Views.xml" XPath="Views/View"/>

And RadListBox looks like this:

<telerik:RadListBox BorderThickness="0,0,2,0" x:Name="lbViews"<br>                            SelectionChanged="lbViews_SelectionChanged"<br>                            SelectedValuePath="@Path"    <br>                            DisplayMemberPath="@Caption"><br>            <telerik:RadListBox.ItemsSource><br>                <Binding Source="{StaticResource xdpViews}"/><br>            </telerik:RadListBox.ItemsSource><br>        </telerik:RadListBox>

 

While DisplayMemberPath works as intended and list box display captions, when I select item selected value is always null. Am I missing something or this is the bug in RadListBox control?

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 10 Feb 2017, 10:02 AM
Hello Igor,

Generally speaking, the selection mechanism of the control does not depend on the type of data source it is populated with. If the data source is properly loaded, the selection should be behaving as expected. With this in mind, may I kindly ask you to try replicating the same behavior with a standard MS ListBox? Does it differentiate in any manner?

Regards,
Stefan X1
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Igor Stefanovic
Top achievements
Rank 1
answered on 10 Feb 2017, 06:27 PM
With regular ListBox it works just fine. When I select item selected value is updated accordingly. It looks like problem with RadListBox.
0
Stefan
Telerik team
answered on 15 Feb 2017, 03:21 PM
Hi Igor,

Thank you for this clarification.

After investigating the case, it seems that the problem is indeed with RadListBox. I have logged it in our bug tracking system. You can track its state in the Feedback Portal: When using an XML as a data source and the SelectedValuePath is set, the SelectedValue is always null.

As stated in the description of the item, you can utilize the SelectedItem property of the control as a workaround.

I have also updated your Telerik points as a token of gratitude for your cooperation in reporting the issue.

All the best,
Stefan X1
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
ListBox
Asked by
Igor Stefanovic
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Igor Stefanovic
Top achievements
Rank 1
Share this question
or