Dear Telerik,
I have a Master-Details window where the Master list is a ListView, and the SelectedItem of this ListView binded to a "SelectedObject" property in my ViewModel.
The Details view should be a RadPropertyGrid, so the RadPropertyGrid's DataItem binded to this "SelectedObject" property as well.
This works fine, however it's very slow to change the selected Item. After I logged the runtime binding errors and warnings, I found that there are lots of "Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=FieldIndicatorVisibility" warnings in the logs.
It seems that the DataItem is null for some reason, however the PropertyGrid shows the properties perfectly. I'm not sure, maybe the PropertyGrid tries to get the "SelectedObject" when it's null, but it is never null, I tried many things to fix the issue, but still nothing. The SelectedObject is not a big ViewModel and the ViewModel implmenets the INotifyPropertyChange.
Let me show you high scope exampe:
View:
<!--The master list in the View (The Objects property is an ObservableCollection<MyObject>, the SelectedObject is a MyObject, both implement INotifyPropertyChanged)-->
<ListView ItemsSource="{Binding Objects}" SelectedItem="{Binding SelectedObject, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ... />
<!-- The details PropertyGrid. The Item binded to the same SelectedObject property. The SelectedObject is never null, but the DataItem is null sometimes -->
<telerik:RadPropertyGrid Item="{Binding SelectedObject, UpdateSourceTrigger=PropertyChanged}" AutoGeneratePropertyDefinitions="False">
<telerik:RadPropertyGrid.PropertyDefinitions>
<!-- Most of the properties have custom EditorTemplate, mostly NumericUpDown controls but not all of them, but it does not related to my problem -->
<telerik:PropertyDefinition Binding="{BindingMyProperty1}" DisplayName="..." Description="... >
<telerik:PropertyDefinition.EditorTemplate>
<DataTemplate DataType="view:MyObject">
<telerik:RadNumericUpDown Value="{Binding MyProperty1, Mode=TwoWay}" />
</DataTemplate>
</telerik:PropertyDefinition.EditorTemplate>
</telerik:PropertyDefinition>
<!-- Another property ans so on... There are 20 properties in the PropertyDefinitions -->
<telerik:PropertyDefinition Binding="{BindingMyProperty2}" DisplayName="..." Description="... >
<telerik:PropertyDefinition.EditorTemplate>
<DataTemplate DataType="view:MyObject">
<telerik:RadNumericUpDown Value="{Binding MyProperty2, Mode=TwoWay}" />
</DataTemplate>
</telerik:PropertyDefinition.EditorTemplate>
</telerik:PropertyDefinition>
</telerik:RadPropertyGrid.PropertyDefinitions>
</telerik:RadPropertyGrid>
ViewModel:
public class ExampleViewModel : BaseViewModelWithNotifyPropertyChanged
{
// The the SelectedItem of the List and Item of the PropertyGrid. Never null
private MyObject _selectedObject;
public MyObject SelectedObject
{
get { return_selectedObject; }
set { SetProperty(ref_selectedObject, value); }
}
// The ItemsSource of the ListView. Always fileld with not null MyObjects
private ObservableCollection<MyObject> _objects;
public ObservableCollection<MyObject> Objects
{
get { return _objects; }
set { SetProperty(ref _objects, value); }
}
}
With this settings, I've got many-many errors. Most of the errors refers the FieldIndicatorVisibility property, not sure why:
- System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=FieldIndicatorVisibility; DataItem=null; target element is 'Grid' (Name=''); target property is 'Visibility' (type 'Visibility')
The common problem is that the DataItem=null. As far as I can see, the DataItem should be a MyObject instace (the same as the SelectedObject property in the ViewModel). Also interesting that the view is working, so its like the PropertyGrid didn't find the DataItem and retry to get the DataItem, and at least the ProeprtyGrid founds the DataItem. It's slow.
It is mission critical to resolve this issue, would you please help me?
Thanks in advance,
Daniel
I have a Master-Details window where the Master list is a ListView, and the SelectedItem of this ListView binded to a "SelectedObject" property in my ViewModel.
The Details view should be a RadPropertyGrid, so the RadPropertyGrid's DataItem binded to this "SelectedObject" property as well.
This works fine, however it's very slow to change the selected Item. After I logged the runtime binding errors and warnings, I found that there are lots of "Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=FieldIndicatorVisibility" warnings in the logs.
It seems that the DataItem is null for some reason, however the PropertyGrid shows the properties perfectly. I'm not sure, maybe the PropertyGrid tries to get the "SelectedObject" when it's null, but it is never null, I tried many things to fix the issue, but still nothing. The SelectedObject is not a big ViewModel and the ViewModel implmenets the INotifyPropertyChange.
Let me show you high scope exampe:
View:
<!--The master list in the View (The Objects property is an ObservableCollection<MyObject>, the SelectedObject is a MyObject, both implement INotifyPropertyChanged)-->
<ListView ItemsSource="{Binding Objects}" SelectedItem="{Binding SelectedObject, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ... />
<!-- The details PropertyGrid. The Item binded to the same SelectedObject property. The SelectedObject is never null, but the DataItem is null sometimes -->
<telerik:RadPropertyGrid Item="{Binding SelectedObject, UpdateSourceTrigger=PropertyChanged}" AutoGeneratePropertyDefinitions="False">
<telerik:RadPropertyGrid.PropertyDefinitions>
<!-- Most of the properties have custom EditorTemplate, mostly NumericUpDown controls but not all of them, but it does not related to my problem -->
<telerik:PropertyDefinition Binding="{BindingMyProperty1}" DisplayName="..." Description="... >
<telerik:PropertyDefinition.EditorTemplate>
<DataTemplate DataType="view:MyObject">
<telerik:RadNumericUpDown Value="{Binding MyProperty1, Mode=TwoWay}" />
</DataTemplate>
</telerik:PropertyDefinition.EditorTemplate>
</telerik:PropertyDefinition>
<!-- Another property ans so on... There are 20 properties in the PropertyDefinitions -->
<telerik:PropertyDefinition Binding="{BindingMyProperty2}" DisplayName="..." Description="... >
<telerik:PropertyDefinition.EditorTemplate>
<DataTemplate DataType="view:MyObject">
<telerik:RadNumericUpDown Value="{Binding MyProperty2, Mode=TwoWay}" />
</DataTemplate>
</telerik:PropertyDefinition.EditorTemplate>
</telerik:PropertyDefinition>
</telerik:RadPropertyGrid.PropertyDefinitions>
</telerik:RadPropertyGrid>
ViewModel:
public class ExampleViewModel : BaseViewModelWithNotifyPropertyChanged
{
// The the SelectedItem of the List and Item of the PropertyGrid. Never null
private MyObject _selectedObject;
public MyObject SelectedObject
{
get { return_selectedObject; }
set { SetProperty(ref_selectedObject, value); }
}
// The ItemsSource of the ListView. Always fileld with not null MyObjects
private ObservableCollection<MyObject> _objects;
public ObservableCollection<MyObject> Objects
{
get { return _objects; }
set { SetProperty(ref _objects, value); }
}
}
With this settings, I've got many-many errors. Most of the errors refers the FieldIndicatorVisibility property, not sure why:
- System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=FieldIndicatorVisibility; DataItem=null; target element is 'Grid' (Name=''); target property is 'Visibility' (type 'Visibility')
The common problem is that the DataItem=null. As far as I can see, the DataItem should be a MyObject instace (the same as the SelectedObject property in the ViewModel). Also interesting that the view is working, so its like the PropertyGrid didn't find the DataItem and retry to get the DataItem, and at least the ProeprtyGrid founds the DataItem. It's slow.
It is mission critical to resolve this issue, would you please help me?
Thanks in advance,
Daniel