C# 视图不';t更新wpf mvvm应用程序中的另一个视图

C# 视图不';t更新wpf mvvm应用程序中的另一个视图,c#,wpf,unity-container,prism,C#,Wpf,Unity Container,Prism,我正在开发wpf应用程序。我有一个壳,它有一个区域。我有两个视图,一个用于编辑person对象,另一个用于列出所有人员(可观察的集合)。两个视图工作正常 每当我使用人员列表视图和更新实体并切换到人员视图时,我都会看到更新的实体。在“人员”视图中更改实体并再次返回“人员”视图后,不会更新视图。(我在使用棱镜和统一)我卡住了 提前谢谢 //我的个人课 public class Personel : ModelBase, IPerson { [Key] public int Perso

我正在开发wpf应用程序。我有一个壳,它有一个区域。我有两个视图,一个用于编辑person对象,另一个用于列出所有人员(可观察的集合)。两个视图工作正常

每当我使用人员列表视图和更新实体并切换到人员视图时,我都会看到更新的实体。在“人员”视图中更改实体并再次返回“人员”视图后,不会更新视图。(我在使用棱镜和统一)我卡住了

提前谢谢

//我的个人课

public class Personel : ModelBase, IPerson
{
    [Key]
    public int PersonelId { get; set; }

    public string Ad { get; set; }

    public int CinsiyetId { get; set; }

    public DateTime DogumTarihi { get; set; }

    public string DogumYeri { get; set; }

    public string Foto { get; set; }

    public string IkinciAd { get; set; }

    public int SaglikDurumId { get; set; }

    public string SaglikSorun { get; set; }

    public string Soyad { get; set; }

    public int TahsilId { get; set; }

    public long TCKN { get; set; }

    public string BabaAdi { get; set; }

    public string AnneAdi { get; set; }

    public int NüfusIlId { get; set; }//+

    public string NüfusIlce { get; set; }

    public string Mahalle { get; set; }

    public int CiltNo { get; set; }

    public int AileSiraNo { get; set; }

    public int SiraNo { get; set; }

    public bool MedeniHal { get; set; }

    public DateTime EvlilikTarih { get; set; }

    public int TelefonAsil { get; set; }

    public int TelefonYedek { get; set; }

    public int TelefonEv { get; set; }

    //public string Adres { get; set; }

    //public int IsActive { get; set; }

    //public string Sicil { get; set; }

    public int Boy { get; set; }

    public int Kilo { get; set; }

    public int KanGrubuId { get; set; }//+

    public bool Sigara { get; set; }

    public int YabanciDilId { get; set; }//+

    public int YabanciDilDurumId { get; set; }//+

}
MainWindow.xaml

<Window x:Class="Nehir.YBS.Views.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:prism="http://prismlibrary.com/"
        prism:ViewModelLocator.AutoWireViewModel="True"
        Title="{Binding Title}" Height="700" Width="1280" ShowInTaskbar="False" WindowStartupLocation="CenterScreen" WindowState="Maximized">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.15*"/>
            <ColumnDefinition Width="0.85*"/>
        </Grid.ColumnDefinitions>
        <TreeView Grid.Column="0" Grid.RowSpan="2">
            <TreeViewItem Header="Lists">
                <Hyperlink Command="{Binding NavigateCommand}" CommandParameter="Personel">Personnel List</Hyperlink>                
            </TreeViewItem>
            <TreeViewItem Header="Editing">
                <Hyperlink  Command="{Binding NavigateCommand}" CommandParameter="PersonelInfo">Personnel</Hyperlink>                
            </TreeViewItem>
        </TreeView>
        <Grid Grid.Row="0" Grid.Column="1" Grid.RowSpan="2">
            <ContentControl prism:RegionManager.RegionName="ContentRegion"  VerticalAlignment="Top" HorizontalAlignment="Stretch" />
        </Grid>
    </Grid>
</Window>

人员名单
全体人员
MainWindowViewModel.cs

public class MainWindowViewModel : BindableBase
    {
        private string _title = "Prism Unity Application";
        public string Title
        {
            get { return _title; }
            set { SetProperty(ref _title, value); }
        }

        private readonly IRegionManager regionManager;

        public DelegateCommand<string> NavigateCommand { get; set; }

        public MainWindowViewModel(IRegionManager regionManager)
        {
            this.regionManager = regionManager;
            NavigateCommand = new DelegateCommand<string>(Navigate);
        }

        private void Navigate(string uri)
        {
            this.regionManager.RequestNavigate("ContentRegion", uri);
        }
    }
public class PersonelViewModel : BindableBase
    {
        Repository<Personel, YBSDbContext> repo = new Repository<Personel, YBSDbContext>(new YBSDbContext());

        private ObservableCollection<Personel> personelList;

        public ObservableCollection<Personel> PersonelList
        {
            get { return personelList; }
            set
            {
                SetProperty(ref personelList, value);
            }
        }

        public PersonelViewModel()
        {
            UpdateCommand = new DelegateCommand(Execute, CanExecute);
            PersonelList = new ObservableCollection<Personel>(repo.GetAll());
        }

        private bool CanExecute()
        {
            if (PersonelList is ObservableCollection<Personel>)
            {
                return true;    
            }
            return false;
        }

        private void Execute()
        {
            repo.Save();
        }

        public DelegateCommand UpdateCommand { get; set; }
    }
public class PersonelInfoViewModel : BindableBase
    {
        Repository<Personel, YBSDbContext> repo = new Repository<Personel, YBSDbContext>(new YBSDbContext());

    private Personel personelInfo;

    public Personel PersonelInfo
    {
        get { return personelInfo; }
        set
        {
            SetProperty(ref personelInfo, value);
        }
    }



public PersonelInfoViewModel()

{
    UpdateCommand = new DelegateCommand(Execute,CanExecute);
    personelInfo = repo.FindBy(p => p.TCKN == 11111111111).Single();//for example
}

private bool CanExecute()
{
    return PersonelInfo is Personel;
}

private void Execute()
{
    repo.Save();   
}

public DelegateCommand UpdateCommand { get; set; }
公共类MainWindowViewModel:BindableBase { 私有字符串_title=“Prism Unity应用程序”; 公共字符串标题 { 获取{return\u title;} 集合{SetProperty(ref _title,value);} } 专用只读IRegionManager regionManager; 公共DelegateCommand导航命令{get;set;} 公共主窗口视图模型(IRegionManager regionManager) { this.regionManager=regionManager; NavigateCommand=新的DelegateCommand(导航); } 私有void导航(字符串uri) { this.regionManager.RequestNavigate(“ContentRegion”,uri); } } Personel.xaml

<UserControl x:Class="Nehir.YBS.Views.Personel"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:Nehir.YBS.Views"
             xmlns:prism="http://prismlibrary.com/"
             prism:ViewModelLocator.AutoWireViewModel="True"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="800">
    <Grid VerticalAlignment="Top">
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <DataGrid x:Name="personelDataGrid" Grid.Row="0" ItemsSource="{Binding PersonelList,UpdateSourceTrigger=PropertyChanged}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" Margin="0,0,280,0">
            <DataGrid.Columns>
                <DataGridTextColumn Header="PersonelId" Binding="{Binding PersonelId, UpdateSourceTrigger=PropertyChanged}"/>
                <DataGridTextColumn Header="Ad" Binding="{Binding Ad, UpdateSourceTrigger=PropertyChanged}"/>
                <DataGridTextColumn Header="Ad2" Binding="{Binding IkinciAd, UpdateSourceTrigger=PropertyChanged}"/>
                <DataGridTextColumn Header="Soyad" Binding="{Binding Soyad, UpdateSourceTrigger=PropertyChanged}"/>
                <DataGridTemplateColumn Header="Doğum Tarihi">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <DatePicker SelectedDate="{Binding DogumTarihi, UpdateSourceTrigger=PropertyChanged}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
        <Button Content="Kaydet" Grid.Row="1" Command="{Binding UpdateCommand}" Width="75" Height="35" Margin="15,0,15,0" VerticalAlignment="Bottom" HorizontalAlignment="Left"/>
    </Grid>
</UserControl>

PersonelViewModel.cs

public class MainWindowViewModel : BindableBase
    {
        private string _title = "Prism Unity Application";
        public string Title
        {
            get { return _title; }
            set { SetProperty(ref _title, value); }
        }

        private readonly IRegionManager regionManager;

        public DelegateCommand<string> NavigateCommand { get; set; }

        public MainWindowViewModel(IRegionManager regionManager)
        {
            this.regionManager = regionManager;
            NavigateCommand = new DelegateCommand<string>(Navigate);
        }

        private void Navigate(string uri)
        {
            this.regionManager.RequestNavigate("ContentRegion", uri);
        }
    }
public class PersonelViewModel : BindableBase
    {
        Repository<Personel, YBSDbContext> repo = new Repository<Personel, YBSDbContext>(new YBSDbContext());

        private ObservableCollection<Personel> personelList;

        public ObservableCollection<Personel> PersonelList
        {
            get { return personelList; }
            set
            {
                SetProperty(ref personelList, value);
            }
        }

        public PersonelViewModel()
        {
            UpdateCommand = new DelegateCommand(Execute, CanExecute);
            PersonelList = new ObservableCollection<Personel>(repo.GetAll());
        }

        private bool CanExecute()
        {
            if (PersonelList is ObservableCollection<Personel>)
            {
                return true;    
            }
            return false;
        }

        private void Execute()
        {
            repo.Save();
        }

        public DelegateCommand UpdateCommand { get; set; }
    }
public class PersonelInfoViewModel : BindableBase
    {
        Repository<Personel, YBSDbContext> repo = new Repository<Personel, YBSDbContext>(new YBSDbContext());

    private Personel personelInfo;

    public Personel PersonelInfo
    {
        get { return personelInfo; }
        set
        {
            SetProperty(ref personelInfo, value);
        }
    }



public PersonelInfoViewModel()

{
    UpdateCommand = new DelegateCommand(Execute,CanExecute);
    personelInfo = repo.FindBy(p => p.TCKN == 11111111111).Single();//for example
}

private bool CanExecute()
{
    return PersonelInfo is Personel;
}

private void Execute()
{
    repo.Save();   
}

public DelegateCommand UpdateCommand { get; set; }
公共类PersonelViewModel:BindableBase
{
Repository repo=新存储库(new YBSDbContext());
私人观察收集人员;
公共观察收集人员
{
获取{return personelList;}
设置
{
SetProperty(参考personelList,值);
}
}
公共人员视图模型()
{
UpdateCommand=新的DelegateCommand(执行,CanExecute);
PersonelList=新的ObservableCollection(repo.GetAll());
}
私人布尔CanExecute()
{
如果(人员列表是可观察的集合)
{
返回true;
}
返回false;
}
私有void Execute()
{
repo.Save();
}
公共DelegateCommand UpdateCommand{get;set;}
}
PersoonelInfo.xaml

<UserControl x:Class="Nehir.YBS.Views.PersonelInfo"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:prism="http://prismlibrary.com/"             
             prism:ViewModelLocator.AutoWireViewModel="True"
             VerticalAlignment="Top">
    <Grid VerticalAlignment="Top">
        <Grid.RowDefinitions>
            <RowDefinition Height="0.95*"/>
            <RowDefinition Height="0.05*"/>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Orientation="Vertical" VerticalAlignment="Top">
            <Expander x:Name="temel" Header="Personel Kişisel Bilgileri" MinWidth="1000" HorizontalAlignment="Left" VerticalAlignment="Top">
                <Grid Background="#FFE5E5E5"  Width="1000">
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="0,15*"/>
                        <ColumnDefinition Width="0,35*"/>
                        <ColumnDefinition Width="0,15*"/>
                        <ColumnDefinition Width="0,35*"/>
                    </Grid.ColumnDefinitions>
                    <TextBox Text="{Binding PersonelInfo.PersonelId, UpdateSourceTrigger=PropertyChanged}" Grid.Row="0" Grid.Column="1"/>
                    <TextBox Text="{Binding PersonelInfo.Ad, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" Grid.Column="1"/>
                    <TextBox Text="{Binding PersonelInfo.IkinciAd, UpdateSourceTrigger=PropertyChanged}" Grid.Row="2" Grid.Column="1"/>
                    <TextBox Text="{Binding PersonelInfo.Soyad, UpdateSourceTrigger=PropertyChanged}" Grid.Row="3" Grid.Column="1"/>
                    <TextBox Text="{Binding PersonelInfo.DogumTarihi, UpdateSourceTrigger=PropertyChanged}" Grid.Row="4" Grid.Column="1"/>
                    <TextBox Text="{Binding PersonelInfo.DogumYeri, UpdateSourceTrigger=PropertyChanged}" Grid.Row="5" Grid.Column="1"/>
                    <TextBox Text="{Binding PersonelInfo.TCKN, UpdateSourceTrigger=PropertyChanged}" Grid.Row="6" Grid.Column="1"/>
                    <TextBox Text="{Binding PersonelInfo.Foto, UpdateSourceTrigger=PropertyChanged}" Grid.Row="7" Grid.Column="1"/>
                    <TextBox Text="{Binding PersonelInfo.AnneAdi, UpdateSourceTrigger=PropertyChanged}" Grid.Row="8" Grid.Column="1"/>
                    <TextBox Text="{Binding PersonelInfo.BabaAdi, UpdateSourceTrigger=PropertyChanged}" Grid.Row="9" Grid.Column="1"/>
                    <TextBox Text="{Binding PersonelInfo.MedeniHal, UpdateSourceTrigger=PropertyChanged}" Grid.Row="10" Grid.Column="1"/>
                    <TextBox Text="{Binding PersonelInfo.EvlilikTarih, UpdateSourceTrigger=PropertyChanged}" Grid.Row="11" Grid.Column="1"/>
                    <TextBlock Text="PersonelId" Grid.Row="0" Grid.Column="0"/>
                    <TextBlock Text="Ad" Grid.Row="1" Grid.Column="0"/>
                    <TextBlock Text="IkinciAd" Grid.Row="2" Grid.Column="0"/>
                    <TextBlock Text="Soyad" Grid.Row="3" Grid.Column="0"/>
                    <TextBlock Text="DogumTarihi" Grid.Row="4" Grid.Column="0"/>
                    <TextBlock Text="DogumYeri" Grid.Row="5" Grid.Column="0"/>
                    <TextBlock Text="TCKN" Grid.Row="6" Grid.Column="0"/>
                    <TextBlock Text="Foto" Grid.Row="7" Grid.Column="0"/>
                    <TextBlock Text="AnneAdi" Grid.Row="8" Grid.Column="0"/>
                    <TextBlock Text="BabaAdi" Grid.Row="9" Grid.Column="0"/>
                    <TextBlock Text="MedeniHal" Grid.Row="10" Grid.Column="0"/>
                    <TextBlock Text="EvlilikTarihi" Grid.Row="11" Grid.Column="0"/>
                </Grid>
            </Expander>
            <Expander x:Name="egitim_saglik"  Header="Eğitim/Sağlık Bilgileri" HorizontalAlignment="Left" VerticalAlignment="Top">
                <Grid Background="#FFE5E5E5" Width="1000">
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="0,15*"/>
                        <ColumnDefinition Width="0,35*"/>
                        <ColumnDefinition Width="0,15*"/>
                        <ColumnDefinition Width="0,35*"/>
                    </Grid.ColumnDefinitions>
                    <TextBox Text="{Binding PersonelInfo.SaglikDurumId, UpdateSourceTrigger=PropertyChanged}" Grid.Row="0" Grid.Column="1"/>
                    <TextBox Text="{Binding PersonelInfo.SaglikSorun, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" Grid.Column="1"/>
                    <TextBox Text="{Binding PersonelInfo.Boy, UpdateSourceTrigger=PropertyChanged}" Grid.Row="2" Grid.Column="1"/>
                    <TextBox Text="{Binding PersonelInfo.Kilo, UpdateSourceTrigger=PropertyChanged}" Grid.Row="3" Grid.Column="1"/>
                    <TextBox Text="{Binding PersonelInfo.KanGrubuId, UpdateSourceTrigger=PropertyChanged}" Grid.Row="4" Grid.Column="1"/>
                    <TextBox Text="{Binding PersonelInfo.Sigara, UpdateSourceTrigger=PropertyChanged}" Grid.Row="5" Grid.Column="1"/>
                    <TextBlock Text="Sağlık Durumu" Grid.Row="0" Grid.Column="0"/>
                    <TextBlock Text="Sağlık Sorunu" Grid.Row="1" Grid.Column="0"/>
                    <TextBlock Text="Boy" Grid.Row="2" Grid.Column="0"/>
                    <TextBlock Text="Kilo" Grid.Row="3" Grid.Column="0"/>
                    <TextBlock Text="Kan Grubu" Grid.Row="4" Grid.Column="0"/>
                    <TextBlock Text="Sigara" Grid.Row="5" Grid.Column="0"/>
                    <TextBox Text="{Binding PersonelInfo.TahsilId, UpdateSourceTrigger=PropertyChanged}" Grid.Row="0" Grid.Column="3"/>
                    <TextBox Text="{Binding PersonelInfo.YabanciDilId, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" Grid.Column="3"/>
                    <TextBox Text="{Binding PersonelInfo.YabanciDilDurumId, UpdateSourceTrigger=PropertyChanged}" Grid.Row="2" Grid.Column="3"/>
                    <TextBlock Text="TahsilId" Grid.Row="0" Grid.Column="2"/>
                    <TextBlock Text="YabanciDilId" Grid.Row="1" Grid.Column="2"/>
                    <TextBlock Text="YabanciDilDurumId" Grid.Row="2" Grid.Column="2"/>
                </Grid>
            </Expander>
            <Expander x:Name="nufus_iletisim"  Header="Nüfus ve İletişim Bilgileri" HorizontalAlignment="Left" VerticalAlignment="Top">
                <Grid Background="#FFE5E5E5" Width="1000">
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="0,15*"/>
                        <ColumnDefinition Width="0,35*"/>
                        <ColumnDefinition Width="0,15*"/>
                        <ColumnDefinition Width="0,35*"/>
                    </Grid.ColumnDefinitions>
                    <TextBox Text="{Binding PersonelInfo.NüfusIlId, UpdateSourceTrigger=PropertyChanged}" Grid.Row="0" Grid.Column="1"/>
                    <TextBox Text="{Binding PersonelInfo.NüfusIlce, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" Grid.Column="1"/>
                    <TextBox Text="{Binding PersonelInfo.Mahalle, UpdateSourceTrigger=PropertyChanged}" Grid.Row="2" Grid.Column="1"/>
                    <TextBox Text="{Binding PersonelInfo.CiltNo, UpdateSourceTrigger=PropertyChanged}" Grid.Row="3" Grid.Column="1"/>
                    <TextBox Text="{Binding PersonelInfo.AileSiraNo, UpdateSourceTrigger=PropertyChanged}" Grid.Row="4" Grid.Column="1"/>
                    <TextBox Text="{Binding PersonelInfo.SiraNo, UpdateSourceTrigger=PropertyChanged}" Grid.Row="5" Grid.Column="1"/>
                    <TextBlock Text="Nüfus İl" Grid.Row="0" Grid.Column="0"/>
                    <TextBlock Text="Nüfus İlçe" Grid.Row="1" Grid.Column="0"/>
                    <TextBlock Text="Mahalle" Grid.Row="2" Grid.Column="0"/>
                    <TextBlock Text="Cilt No" Grid.Row="3" Grid.Column="0"/>
                    <TextBlock Text="Aile Sıra No" Grid.Row="4" Grid.Column="0"/>
                    <TextBlock Text="Sıra No" Grid.Row="5" Grid.Column="0"/>
                    <TextBox Text="{Binding PersonelInfo.TelefonAsil, UpdateSourceTrigger=PropertyChanged}" Grid.Row="0" Grid.Column="3"/>
                    <TextBox Text="{Binding PersonelInfo.TelefonYedek, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" Grid.Column="3"/>
                    <TextBox Text="{Binding PersonelInfo.TelefonEv, UpdateSourceTrigger=PropertyChanged}" Grid.Row="2" Grid.Column="3"/>
                    <TextBox Text="{Binding PersonelInfo.Adres, UpdateSourceTrigger=PropertyChanged}" Grid.Row="5" Grid.Column="3"/>
                    <TextBlock Text="Telefon" Grid.Row="0" Grid.Column="2"/>
                    <TextBlock Text="Telefon Yedek" Grid.Row="1" Grid.Column="2"/>
                    <TextBlock Text="Telefon Ev" Grid.Row="2" Grid.Column="2"/>
                    <TextBlock Text="Adres" Grid.Row="5" Grid.Column="2"/>
                </Grid>
            </Expander>
        </StackPanel>
        <StackPanel Grid.Row="1" Orientation="Horizontal">
            <Button Content="Kaydet" Command="{Binding UpdateCommand}" Width="75" Margin="15,0,15,0"/>
        </StackPanel>
    </Grid>
</UserControl>

PersonelInfoViewModel.cs

public class MainWindowViewModel : BindableBase
    {
        private string _title = "Prism Unity Application";
        public string Title
        {
            get { return _title; }
            set { SetProperty(ref _title, value); }
        }

        private readonly IRegionManager regionManager;

        public DelegateCommand<string> NavigateCommand { get; set; }

        public MainWindowViewModel(IRegionManager regionManager)
        {
            this.regionManager = regionManager;
            NavigateCommand = new DelegateCommand<string>(Navigate);
        }

        private void Navigate(string uri)
        {
            this.regionManager.RequestNavigate("ContentRegion", uri);
        }
    }
public class PersonelViewModel : BindableBase
    {
        Repository<Personel, YBSDbContext> repo = new Repository<Personel, YBSDbContext>(new YBSDbContext());

        private ObservableCollection<Personel> personelList;

        public ObservableCollection<Personel> PersonelList
        {
            get { return personelList; }
            set
            {
                SetProperty(ref personelList, value);
            }
        }

        public PersonelViewModel()
        {
            UpdateCommand = new DelegateCommand(Execute, CanExecute);
            PersonelList = new ObservableCollection<Personel>(repo.GetAll());
        }

        private bool CanExecute()
        {
            if (PersonelList is ObservableCollection<Personel>)
            {
                return true;    
            }
            return false;
        }

        private void Execute()
        {
            repo.Save();
        }

        public DelegateCommand UpdateCommand { get; set; }
    }
public class PersonelInfoViewModel : BindableBase
    {
        Repository<Personel, YBSDbContext> repo = new Repository<Personel, YBSDbContext>(new YBSDbContext());

    private Personel personelInfo;

    public Personel PersonelInfo
    {
        get { return personelInfo; }
        set
        {
            SetProperty(ref personelInfo, value);
        }
    }



public PersonelInfoViewModel()

{
    UpdateCommand = new DelegateCommand(Execute,CanExecute);
    personelInfo = repo.FindBy(p => p.TCKN == 11111111111).Single();//for example
}

private bool CanExecute()
{
    return PersonelInfo is Personel;
}

private void Execute()
{
    repo.Save();   
}

public DelegateCommand UpdateCommand { get; set; }
公共类PersonelInfoViewModel:BindableBase
{
Repository repo=新存储库(new YBSDbContext());
个人信息;
公共人员
{