Your last answer was:
Can you please try firing the PropertyChanged event
for the Object1Type property
when the other property changes? The DataForm should
detect this change and call the GenericListInfoProvider for
new items.
If that doesn't work, sending us a sample project that we can use to
investigate the case will be really helpful.
Thanks for your time.
Regards,
Deyan
Telerik
5 Answers, 1 is accepted
Please excuse us for the inconvenience. I am not sure what might have happened on your end but your question was answered yesterday. Please have a look at Deyan's answer below:
I have also attached the sample project he prepared for you.
Hi Viktoras,
Thanks for writing back and for the provided project.
I have been able to implement the scenario you require. For that purpose I have additionally implemented theIGenericListEditorConverter interface which is used to translate property values from the MainViewModel to the Data Form and vice-versa. Since an instance of the RadListPicker editor is provided in theConvert method, I am able to change it's data source there according to whether car or phone is selected.
So, in my GenericListInfoProvider implementation for the second list-picker I also use the Converter property from the interface to return an instance of that special type of converter. Take a look at the attached project.
The only issue I have encountered is that the ViewModelLocator which I am using the my conberter to acquire the MainViewModel instance always returns a new instance of it which is not correct. I therefore am not able to retrieve the correct selection - car or phone - so that I can generate a new data source.
I am attaching the modified version of your project for your reference.
Regards,
Victor
Telerik
DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!
I have attached the sample project again.
Regards,
Rosy Topchiyska
Telerik
Hello, this sample project does not seem to work correctly if the number of items in the "Things" list exceed the "InlineModeThreshold" for the list picker.
For example, if Thing1ValueConverter is modified as such...
public object ConvertForEditor(RadListPicker editor, object value)
{
//string things = App.MainViewModel.Things;
MainViewModel model = (MainViewModel)editor.DataContext;
if (model == null) return value;
string things = model.Things;
if (things == null)
{
return value;
}
List<string> source = null;
if (things == "car")
{
editor.ItemsSource = source = new List<string> { "bmw", "alfa", "1", "2", "3", "4", "5" };
}
else if (things == "phone")
{
editor.ItemsSource = source = new List<string> { "nokia", "sony", "1", "2", "3", "4", "5" };
}
return source[0];
}
Then you can no longer pick the items from the list picker.
Thank you for contacting us.
The problem in the attached project is that the RadDataForm.CurrentItem is set to a new instance of MainViewModel class, rather than bound to the context of the page. This in the converter, when checking the value of ViewModelLocator.Main.Things, you will get incorrect value, because the main view model has not changed. If you update the following line of code, the items in the second picker should update correctly:
<
telerikInput:RadDataForm
Margin
=
"12,0,12,12"
x:Name
=
"DataForm"
CommitMode
=
"OnFieldValueChange"
CurrentItem
=
"{Binding}"
>
I hope this helps. If you experience a different issue, please be more specific on the scenario: what happens when you try to select an item?
Regards,
Rosy Topchiyska
Telerik