here my code
public class NodeDetails
{
public string Name { get; set; }
public string Size { get; set; }
public ushort DateModified { get; set; }
public string FType { get; set; }
public string Path { get; set; }
public ImageSource ListIcon { get; set; }
}
public class ViewModel : ViewModelBase
{
private NodeDetails _student;
private ObservableCollection<nodedetails> _students;
private ICommand _SubmitCommand;
public NodeDetails Student
{
get
{
return _student;
}
set
{
_student = value;
NotifyPropertyChanged("Student");
}
}
public ObservableCollection<nodedetails> Students
{
get
{
return _students;
}
set
{
_students = value;
NotifyPropertyChanged("Students");
}
}
public ICommand SubmitCommand
{
get
{
if (_SubmitCommand == null)
{
_SubmitCommand = new RelayCommand(param => this.Submit(),
null);
}
return _SubmitCommand;
}
}
public ViewModel()
{
Student = new NodeDetails();
Students = new ObservableCollection<nodedetails>();
Students.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Students_CollectionChanged);
}
public void Students_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
NotifyPropertyChanged("Students");
}
public void Submit()
{
Students = new ObservableCollection<nodedetails>(Global.GnodeDetails);
}
}
public class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
public class RelayCommand : ICommand
{
public RelayCommand(Action<object> execute) : this(execute, null)
{
}
public RelayCommand(Action<object> execute, Predicate<object> canExecute)
{
if (execute == null)
throw new ArgumentNullException("execute");
_execute = execute;
_canExecute = canExecute;
}
public bool CanExecute(object parameter)
{
return _canExecute == null ? true : _canExecute(parameter);
}
public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
public void Execute(object parameter)
{
_execute(parameter);
}
private readonly Action<object> _execute;
private readonly Predicate<object> _canExecute;
}
////Xaml code
<local:treeviewcontrol grid.column="0" background="#F9F9F9" horizontalalignment="Left" verticalalignment="Top" height="540" width="230" margin="0,0,0,0">
<listview grid.column="1" itemssource="{Binding Students}">
<listview.view>
<gridview>
<gridviewcolumn header="Name" celltemplate="{StaticResource myCellTemplateMonth}" width="200">
<gridviewcolumn header="Size" width="60" displaymemberbinding="{Binding Size}">
<gridviewcolumn header="DateModified" width="150" displaymemberbinding="{Binding DateModified}">
<gridviewcolumn header="Type" width="70" displaymemberbinding="{Binding FType}">
<gridviewcolumn header="Path" width="150" displaymemberbinding="{Binding Path}">
<pre>
<pre> <Button Height="40" Width="105" Margin="0,0,20,0" Grid.Column="1" Command="{Binding SubmitCommand}" HorizontalAlignment="Right" Background="#8E8E8E">
<StackPanel>
<TextBlock Text="Recover" FontSize="18" Foreground="#F9F9F9"/>
</StackPanel>
</Button>
My problem is when I use the Recover button the listview is update in UI. I have given above one treecontrol(custom control) in that view model if I get any value I need to update the UI cant able to use the list view from other classes.
What I have tried:
class tree
{
public void accesss()
{
Viewmodel tem=new Viewmodel();
tem.submit();
}
}
I need to access the list from other class