Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8838495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:00:40+00:00 2026-06-14T10:00:40+00:00

I have a datagrid bound to a Players property: <DataGrid HorizontalAlignment=Left SelectedItem={Binding CurrentPlayer} Height=374

  • 0

I have a datagrid bound to a Players property:

 <DataGrid HorizontalAlignment="Left" SelectedItem="{Binding CurrentPlayer}" Height="374" Margin="121,22,0,0" RowHeaderWidth="0" VerticalAlignment="Top" Width="836" ItemsSource="{Binding Players}" AutoGenerateColumns="false" IsReadOnly="True" SelectionMode="Single" IsEnabled="{Binding Editing, Converter={StaticResource InverseBooleanConverter}}" Grid.RowSpan="2" Grid.ColumnSpan="2">

This Players property is defined like this:

public List<Player> Players
{
    get { return repository.Players.OrderBy(x => x.Firstname).ToList(); }
}

The repository contains a DBSet from EF.

When I add a player, I use this code:

private void SaveExecute(object parameter)
{
    repository.SavePlayer(currentPlayer);
    Editing = false;
}

What I’d like to do now is simple: when the new player is created, the datagrid should refresh. It’s bound to the Players property, but no setter is ever used and so calling RaisePropertyChange is not possible there.

I’m stuck here. How to correctly bind it so that when the SavePlayer()-method is called, the datagrid would update and so the new player is shown?

The easiest solution I’ve found is calling RaisePropertyChanged(“Players”); in the SaveExecute() method:

private void SaveExecute(object parameter)
{
    repository.SavePlayer(currentPlayer);
    RaisePropertyChanged("Players");
    Editing = false;
}

But… is this allowed or is this something you shouldn’t do? Should you only call RaiseProperyChanged in setters of properties of would this be fine too?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:00:41+00:00Added an answer on June 14, 2026 at 10:00 am

    change the List<Player> for an ObservableCollection<Player>. This is a special type of collection that has events to notify when items are added / removed from it. WPF automatically handles these events and updates the UI accordingly.

    Then in your Save(), just Players.Add(newitem); and you will see the changes reflected in the UI.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a datagrid, bound to a List: <DataGrid HorizontalAlignment=Left SelectedItem={Binding CurrentPlayer} Height=374 Margin=121,22,0,0
I have a DataGrid that I have bound to a property: <cd:DataGrid Name=myDataGrid ItemsSource={Binding
I have a DataGrid bound to a DomainDataSource: <sdk:DataGrid AutoGenerateColumns=False Height=Auto ItemsSource={Binding ElementName=mailboxDomainDataSource, Path=Data,Mode=TwoWay}
I have Datagrid which is bound to my Database <WpfToolkit:DataGrid Name=DataGrid1 Grid.Row=1 ItemsSource={Binding Path=MainSearchBinding}
I have a DataGrid bound to a ViewModel's property of type ObservableCollection. Inside DataGrid
i have a datagrid bound to a property. In this grid i have columns
I have WPF combobox bound to a ObservableCollection ItemCategoryList <ComboBox Grid.Column=1 Grid.Row=2 Height=Auto HorizontalAlignment=Stretch
I have a DataGrid bound to a PagedCollectionview property of my View-Model. I've added
I have a DataGrid in WPF bound to an observable collection. In my UI
I have a simple Silverlight 5 datagrid bound to a ObservableCollection of objects: <sdk:DataGrid

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.