我目前在UWP中使用telerik来创建项目列表,我希望能够使用浏览按钮并更新Telerik-RadDataForm中的某个数据。我使用MVVM设置了所有绑定,如果没有在代码端进行编辑,它会显示数据。我的XAML设置如下:
<Data:RadDataForm x:Name="dataform"
HorizontalAlignment="Left" Grid.Row="0"
Grid.RowSpan="2" Grid.Column="2"
VerticalAlignment="Center" Width="454"
Item="{Binding CurrentSceneViewModel, Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" CommitMode="Immediate"
ValidationMode="Immediate" Height="664" Margin="0,28" />
CurrentSceneViewModel是:
public SceneViewModel CurrentSceneViewModel
{
get => _currentSceneViewModel;
set=> _currentSceneViewModel= value;
}
我希望改变的数据是:
public string FileName
{
get => _fileName;
set
{
Scene.SceneFile = value;
_fileName = Path.GetFileName(value);
OnPropertyChanged(nameof(FileName));
}
}
我遇到的问题是将这些信息推送到用户界面,即使使用PropertyChanged,代码隐藏似乎也不会更新UI。我不确定还能尝试什么?如果这是RadDataform根本不支持的话。应该注意FileName是CurrentScene ViewModel的属性。
public abstract class BaseViewModel: INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
protected IPageNavigationService navservice = new PageNavigationService();
}