Currently i have the problem, that my business object overrides ToString
for delivering data to some telerik control (RadListBox
/RadListBoxItem
). The model which overrides ToString
implements INotifyPropertyChanged.
Is it possible in c# to raise the method ToString
to be changed? The initial values get's displayed well, but later changes will be ignored. For example:
public class ViewModel : UI.MVC.ViewModelBase
{
private string name;
[JsonProperty]
public string Name
{
get
{
return name;
}
set
{
name = value;
RaisePropertyChanged("Name");
}
}
public override string ToString()
{
return name ?? "--";
}
}
For example if Name
is chagned, ToString
should be called to get the new value.
EDIT
The ViewModel
from above is embedded in another viewmodel. which is binded to a RadPropertyGrid
:
public class FirstViewModel : : UI.MVC.ViewModelBase
{
public FirstViewModel()
{
SelectedItem = new ViewModel();
}
public object SelectedItem
{
get;
}
}
An instance of RistViewModel is the datacontext of the containing window.
XAML
<telerik:RadPropertyGrid NestedPropertiesVisibility="Visible"
x:Name="propertyGrid" Grid.Column="1" Grid.Row="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" IsGrouped="True"
Item="{Binding SelectedItem,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
Thank you very much!