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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:26:27+00:00 2026-06-07T18:26:27+00:00

Having a weird problem with two WPF datagrids bound to separate ObservableCollections. Here’s my

  • 0

Having a weird problem with two WPF datagrids bound to separate ObservableCollections.

Here’s my XAML:

<Grid Name="gridShifts">
<Grid.ColumnDefinitions>
    <ColumnDefinition/>
    <ColumnDefinition/>
</Grid.ColumnDefinitions>
    <Custom:C1DataGrid Name="dgShift1"
                       HorizontalAlignment="Left" AutoGenerateColumns="False" CanUserAddRows="False" CanUserRemoveRows="False" CanUserReorderColumns="False" Grid.Column="0">
        <Custom:C1DataGrid.Columns>
            <Custom:DataGridTextColumn Binding="{Binding Path=Type, Mode=TwoWay}" IsReadOnly="True"  Header="Work Center"/>
            <Custom:DataGridTextColumn Binding="{Binding Path=RegularSkill, Mode=TwoWay }" Header="Personnel"/>
        </Custom:C1DataGrid.Columns>
    </Custom:C1DataGrid>
    <Custom:C1DataGrid Name="dgShift2"
                       HorizontalAlignment="Left" AutoGenerateColumns="False" CanUserAddRows="False" CanUserRemoveRows="False" CanUserReorderColumns="False" Grid.Column="1">
        <Custom:C1DataGrid.Columns>
            <Custom:DataGridTextColumn Binding="{Binding Path=Type, Mode=TwoWay}" IsReadOnly="True"  Header="Work Center"/>
            <Custom:DataGridTextColumn Binding="{Binding Path=RegularSkill, Mode=TwoWay }" Header="Personnel"/>
        </Custom:C1DataGrid.Columns>
    </Custom:C1DataGrid>
</Grid>

And here’s my code behind:

public partial class MainWindow : Window
{
    AMMData.Manpower mp = new AMMData.Manpower();

    public MainWindow()
    {
        InitializeComponent();

        gridShifts.DataContext = mp;
        dgShift1.ItemsSource = mp.WorkShifts[0].WCList;
        dgShift2.ItemsSource = mp.WorkShifts[1].WCList;

    }
}

EDIT: Here is the Manpower class:

public enum WCSpecialty
{
    Indirect,
    Airframes,
    AviationLifeSupport,
    PeriodicMaintenance,
    Electronics,
    Electrical_Instruments,
    Armaments,
    Reconnaissance,
    Line,
    NA
}

public class Manpower : ComponentDataWrapper
{
    #region Private Properties

    private ObservableCollection<WCCollection> workShifts = new ObservableCollection<WCCollection>();

    #endregion

    #region Public Properties

    public ObservableCollection<WCCollection> WorkShifts { set { workShifts = value; NotifyPropertyChanged("WorkShifts"); } get { return workShifts; } }

    #endregion


    public Manpower()
    {
        Name = "New Work Center Structure";
        Description = "New Work Center Personnel Description";
        LastChanged = System.DateTime.Now;

        var wcc1 = new AMMData.WCCollection();
        var wcc2 = new AMMData.WCCollection();

        var wc1 = new AMMData.WorkCenter { Type = AMMData.WCSpecialty.Indirect, RegularSkill = 0, MedSkill = 999, HighSkill = 999 };
        var wc2 = new AMMData.WorkCenter { Type = AMMData.WCSpecialty.Airframes, RegularSkill = 0, MedSkill = 999, HighSkill = 999 };
        var wc3 = new AMMData.WorkCenter { Type = AMMData.WCSpecialty.AviationLifeSupport, RegularSkill = 0, MedSkill = 999, HighSkill = 999 };
        var wc4 = new AMMData.WorkCenter { Type = AMMData.WCSpecialty.PeriodicMaintenance, RegularSkill = 0, MedSkill = 999, HighSkill = 999 };
        var wc5 = new AMMData.WorkCenter { Type = AMMData.WCSpecialty.Electronics, RegularSkill = 0, MedSkill = 999, HighSkill = 999 };
        var wc6 = new AMMData.WorkCenter { Type = AMMData.WCSpecialty.Electrical_Instruments, RegularSkill = 0, MedSkill = 999, HighSkill = 999 };
        var wc7 = new AMMData.WorkCenter { Type = AMMData.WCSpecialty.Armaments, RegularSkill = 0, MedSkill = 999, HighSkill = 999 };
        var wc8 = new AMMData.WorkCenter { Type = AMMData.WCSpecialty.Reconnaissance, RegularSkill = 0, MedSkill = 999, HighSkill = 999 };
        var wc9 = new AMMData.WorkCenter { Type = AMMData.WCSpecialty.Line, RegularSkill = 0, MedSkill = 999, HighSkill = 999 };
        var wc10 = new AMMData.WorkCenter { Type = AMMData.WCSpecialty.NA, RegularSkill = 0, MedSkill = 999, HighSkill = 999 };

        wcc1.WCList.Add(wc1);
        wcc1.WCList.Add(wc2);
        wcc1.WCList.Add(wc3);
        wcc1.WCList.Add(wc4);
        wcc1.WCList.Add(wc5);
        wcc1.WCList.Add(wc6);
        wcc1.WCList.Add(wc7);
        wcc1.WCList.Add(wc8);
        wcc1.WCList.Add(wc9);
        wcc1.WCList.Add(wc10);

        wcc2.WCList.Add(wc1);
        wcc2.WCList.Add(wc2);
        wcc2.WCList.Add(wc3);
        wcc2.WCList.Add(wc4);
        wcc2.WCList.Add(wc5);
        wcc2.WCList.Add(wc6);
        wcc2.WCList.Add(wc7);
        wcc2.WCList.Add(wc8);
        wcc2.WCList.Add(wc9);
        wcc2.WCList.Add(wc10);

        WorkShifts.Add(wcc1);
        WorkShifts.Add(wcc2);

    }
}

public class WCCollection : ComponentDataWrapper
{
    private ObservableCollection<WorkCenter> wcList = new ObservableCollection<WorkCenter>();

    public ObservableCollection<WorkCenter> WCList { set { wcList = value; NotifyPropertyChanged("WCList"); } get { return wcList; } }
}

    public class WorkCenter : ComponentDataWrapper
{
    #region private

    private WCSpecialty type;
    private int regularSkill;
    private int highSkill;
    private int medSkill;

    #endregion

    #region public

    public WCSpecialty Type { set { type = value; NotifyPropertyChanged("Type"); } get { return type; } }
    public int RegularSkill { set { regularSkill = value; NotifyPropertyChanged("RegularSkill"); } get { return regularSkill; } }
    public int HighSkill { set { highSkill = value; NotifyPropertyChanged("HighSkill"); } get { return highSkill; } }
    public int MedSkill { set { medSkill = value; NotifyPropertyChanged("MedSkill"); } get { return medSkill; } }

    public int RegularWholePeople { get { return regularSkill / 10; } }

    #endregion
}

My problem is that when I edit one datagrid, the other’s values also change. I’ve tried setting the datacontext for both grids to their respective ObservableCollections, but the same thing happens. I feel like I’m moderately familiar with how WPF databinding works at this point, but I’m completely stumped on this issue. Thanks for any help.

  • 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-07T18:26:28+00:00Added an answer on June 7, 2026 at 6:26 pm

    It looks like your items are being added to your ObservableCollections by reference, not by value.

    This means both collections contain a reference to the same object in memory, so updating an object in one collection is actually updating the single object reference, which causes the other collection to update as well

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

Sidebar

Related Questions

I having a weird problem with Entity Framework with MySql database. Here's the code
I am having a weird problem here, and I am really stuck, need to
Alright, this is a weird problem I'm having. I have two pages, which are
Having a weird problem sprintf(tmp, \%s\, filename); I expect the output to be filename
i'm having a weird problem about copying with Xcopy. I'm using Windows Server 2008
I'm having the weird problem that after having javascript inject some dom-elements the css-rules
I'm having a weird problem with the following function, which returns a string with
I'm having a weird problem with memset, that was something to do with a
I'm having a weird problem with index organized table. I'm running Oracle 11g standard.
I am having a weird problem with sending data back to my server. This

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.