c# - WPF collection binding - Item with same key has already been added -



c# - WPF collection binding - Item with same key has already been added -

i'm trying bind listbox collection of system.windows.points, textbox bound property of listbox selected item. displaying info works fine. listbox populated , desired property of selected bound item displayed in textbox.

the problem when seek edit value via textbox. alter not made item in listbox, , modified property remains in textbox after select item in listbox. if reselect listbox item attempted modify argumentexception thrown "an item same key has been added".

<listbox x:name="pointlist" horizontalalignment="left" height="74" itemssource="{binding mypointlist, mode=twoway}" issynchronizedwithcurrentitem="true" /> <textbox horizontalalignment="left" height="23" text="{binding selecteditem.x, elementname=pointlist, mode=twoway}"/>

and in viewmodel.. i've tried implementing using observablecollection below, , list of points implementing notifychange both same result.

public pointcollection mypointlist { get; private set; } .... public myviewmodel() { mypointlist = new pointcollection (); mypointlist.add(new point (2,2)); mypointlist.add(new point (3,2)); } .... public class pointcollection : observablecollection<point> { public pointcollection() { } }

c# wpf xaml data-binding collections

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -