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 8143901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:14:03+00:00 2026-06-06T13:14:03+00:00

I’ve spent quite a few hours trying to solve the problem described below: I’ve

  • 0

I’ve spent quite a few hours trying to solve the problem described below:

I’ve got a DataGrid defined in my MVVM WPF application, the stripped down XAML code looks like this:

<DataGrid AutoGenerateColumns="False" Name="dgdSomeDataGrid" SelectedItem="{Binding SelectedSomeItem, Mode=TwoWay}" ItemsSource="{Binding SomeItemCollection}">
    <DataGrid.Columns>
        <DataGridTextColumn Binding="{Binding Path=Id}" Header="ID" />
        <DataGridTextColumn Header="Titel" Binding="{Binding Path=Title}" />
        <DataGridTextColumn Header="Status" Binding="{Binding Path=State}" />
    </DataGrid.Columns>
</DataGrid>

In my associated ViewModel I’ve got a corresponding property like:

public WorkItemForUi SelectedSomeItem
{
    get
    {
        return SomeObject.SelectedSomeItem;
    }
    set
    {
        SomeObject.SelectedSomeItem = value;
        OnPropertyChanged( "SelectedSomeItem" );
    }
}

In my controller I’ve got the following:

private void MainWindowViewModelPropertyChanged( object sender, PropertyChangedEventArgs e )
{
    if ( e.PropertyName == "SelectedSomeItem" )
    {
        UpdateSelectedSomeItem();
    }
}

What I generally want to do is to retrieve the selected item from the DataGrid, get some more information about the item from an external data store (a TFS in this case) and show that extra information in a TextBox.

All of this already works as expected, but the problem is that the MainWindowViewModelPropertyChanged method is called twice, not once.

It may be the case that it is by design for the SelectedItem property being set to happen twice, but I’m not quite sure as a lot of information I found is a bit contradictory (and also sometimes not quite clear whether Windows Forms or WPF are meant).

I’ve seen some suggestions where a SelectionChanged event handler is defined for the DataGrid and an IsSelected property is used, but as far as I know this shouldn’t be necessary due to my data binding.

Update
As part of the MainWindowController there is an Initialize method that references the MainWindowViewModelPropertyChanged handler.

    public void Initialize( string tfsProjectCollection )
    {
        InitializeCommands();
        InitializeViewModel();
        AddWeakEventListener( m_MainWindowViewModel, MainWindowViewModelPropertyChanged );
    }

Any ideas what might be the cause of my problem?

  • 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-06T13:14:04+00:00Added an answer on June 6, 2026 at 1:14 pm

    Alright, after spending some more time on this we found out that the problem was in the ApplicationController class.

    The constructor called the Initialize method in that class, and the Run method in the same class also called this method.

    Within the Initialize method there was a call to the main window’s view model `Initialize´ method in which an event listener was added:

    [...]
    AddWeakEventListener( m_MainWindowViewModel, MainWindowViewModelPropertyChanged );
    [...]
    

    Removing the call to the Initialize method from the constructor of the ApplicationController class solved the problem.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
i got an object with contents of html markup in it, for example: string

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.