Automatically update 2 dimensional array based on list content

Suppose I have a simple class named SimplePoint
class SimplePoint
public int x { get; set; }
public int y { get; set; }
Next I create an ObservableCollection of the class and bind it to a WPF DataGrid via XAML.
Each SimplePoint has a distance to each other SimplePoint int the list, resulting in a matrix. The distance from point a to b can be different from the distance from point b to a (ie. different route).Distances should be editable.
I wonder how I can create a class, that can automatically keep track of changes in the ObservableCollection<SimplePoint>. When a new SimplePoint is added, one row and one column should be added to the distances matrix. When a SimpePoint is removed,
the appropriate entries in the matrix should be removed. Later I also wish to store and retrieve all the info to and from an XML via serialization.
So this list:
point1
point2
point3
Would yield a 3x3 matrix of distances.
Searching a lot did not yield results, though I am unsure if I looked for the right thing. I cannot get my head around how to organize this internally. Maybe something like ObservableCollection<ObservableCollection<SimplePoint>>, but then how
to maintain that, and how to bind it to a DataGrid... Any ideas?

Hi mennowo,
>> that can automatically keep track of changes in the ObservableCollection<SimplePoint>. When a new SimplePoint is added, one row and one column should be added to the distances matrix
I would recommend that you can use ObservableCollection<T>.CollectionChanged event:
https://msdn.microsoft.com/en-us/library/ms653375(v=vs.110).aspx
This event will be triggered when items are added, removed, changed, moved, or the entire list is refreshed. In this event, you can easily add item into the distances matrix as you wish.
Here is a simple sample:
public ObservableCollection<SimplePoint> DemoSource { get; set; }
public MainWindow()
InitializeComponent();
DemoSource = new ObservableCollection<SimplePoint>();
DemoSource.CollectionChanged += MyItemsSource_CollectionChanged;
DemoSource.Add(new SimplePoint() { x = 1, y = 1 });
DemoSource.Add(new SimplePoint() { x = 2, y = 2 });
DemoSource.Add(new SimplePoint() { x = 3, y = 3 });
this.DataContext = this;
private void MyItemsSource_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
if (e.NewItems != null)
foreach (SimplePoint item in e.NewItems)
//Add this item into the distances matrix
if (e.OldItems != null)
foreach (SimplePoint item in e.OldItems)
//Do something for old items
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • Display webpart based on list content

    Hello,
    Is is possible to either display a custom home page or a different web part based on if content exists in a list or not?
    I have a list configured for data entry.  From that data, I use SQL reporting services to generate and display graphs and pretty stuff.
    Is is possible, for when a user logs into sharepoint (2013), if they have not entered any data yet, then display the data entry form, or if they have already entered data, display the reporting services dashboards?
    Andrew Huddleston | Hillsong Church | Sydney

    You can use javascript client object model to first check if the current logged in user has the data entered in the list on page load and onsuccess method of your javascript async call you can check if you have retrieved any count for the user in the list.
    If data exists then using jquery either show your reporting webpart or hide it and instead show your data entry form. Below are some pointers
    http://sharepoint.stackexchange.com/questions/73032/get-current-user-in-client-object-model-with-javascript
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/c437ecc4-c757-483f-8175-f92860d184be/hideshow-webpart-data-on-buttonclick-using-jquery?forum=sharepointgeneralprevious
    http://msdn.microsoft.com/en-us/library/office/jj163201%28v=office.15%29.aspx#BasicOps_SPListItemTasks
    Geetanjali Arora | My blogs |

  • MS14-065 (Nov. IE update) breaks domain-based exception list for outdated ActiveX Blocking.

    The November cumulative IE update (MS14-065) appears to break the domain-based exceptions for the new outdated ActiveX control blocking that is described here:
    http://technet.microsoft.com/en-us/library/dn761713.aspx
    We have the new IE group policies deployed in our environment to add domain exceptions for our enterprise to the outdated ActiveX blocking. This was all working perfectly prior to MS14-065. After installing that November update, our exceptions are no longer
    working and users are getting the block message for their Java applications.
    Our environment is Windows 7 SP1 x64 using IE 9. Domain Controllers are 2008 R2.
    If I manually remove MS14-065 (falling back to MS14-056, October update) the exceptions all work again as expected. Re-installing MS14-065 (November update) causes the exceptions to stop working again.
    Thanks,
    Brian

    Hello Brian,
    What is your current situation?
    Have you tried the solution as MVP IECustomizer and Robear Dyer mentioned?
    Best regards,
    Fangzhou CHEN
    Fangzhou CHEN
    TechNet Community Support

  • How can I automatically crop a photo based on its content (a black border)?

    I scanned hundred of negatives.
    The scanner produced .jpg files.  Most of the scanned images show the negatives holder to one side as a black border.  The black border is thicker or thinner depending on the photo.
    Please see pictures attached. 
    Is there a way to automate the detection of such a border and remove it by cropping the photo?  Ideally I would like the processing to only remove the thickness that is required to keep the photo unaltered as much as possible.
    I have Photoshop 12 and I know about Actions.  I just don't know how to tell the engine to only crop if it is required, and by how much.
    This could save me days of manual work.  Thankyou.
    Environment Information:
    ·  I am running Photoshop 12.1 *64 bit
    ·  Windows 7 Professional 64 bit
    ·  Amount of installed RAM: 6GB
    ·       Scanner:  Canon CanoScan 8800F
    ·  Amount of free disk space:
                C:\ - OS and Software disk - Total size:139GB showing 20GB free
                G:\ - Data disk - Total size:1.81 TB showing 437GB free
    ·  Make/Model of Video Card: NVIDIA GeForce 9600 GT

    Thank you miss marple for your Image>Canvas Size... suggestion.  I used it to implement a semi automated process.
    I programmed a couple of actions:
    - one to trim all sides by 7 pixels
    - one to trim the top side by 7 pixles
    Then I assigned a shortcut key to each action.
    Since I have to open each photo individually anyway to remove larger scratches (see my other post), it is easy to hit a couple of keyboard keys to trigger the relevant 'border removal' action.
    The main thing is that in 95% of cases I don't have to use the mouse to fix the borders, but I use keyboard keys only.  It is a real time saver.

  • How do I update items on a 2nd list based on data changes on the first list

    Hi everyone, let me start by saying I am still learning about Sharepoint - what it can or can't do etc. I am also not a developer by nature. So it may take me little while to understand. Thanks for your patience and help.
    I am currently working on Sharepoint 2007.
    I have a Booking form and an Inventory form.
    With the booking from I have a column where the user can select the inventory item to book e.g. BookedItem
    With the inventory form I have a Availability column. (i.e. It's a text column populated with either Yes or No)
    I've also got a view on the front page of my Sharepoint page showing users what is currently available for booking. This is just a filtered view of Inventory form. Basically it displays items where Availability = Yes.
    What I would like to do is have a workflow that automatically updates the Availability in the Inventory list when an item is booked in the Booking Form.
    E.g Item A is booked via the Booking Form. Item A's availability in the Inventory List should now the 'No'.
    Users should now no longer be able to see Item A as an available item on my Sharepoint page.
    I am struggle with linking the two lists and making the corresponding updates. I'd appreciate it someone could help me out.
    Thanks.

    Hi Anil
    Thanks for the reply. I've attempted the steps in the link as shown but if the issue I am getting is because I am running Sharepoint 2007 instead. The example that you've linked is based on Sharepoint 2010.
    Just to be clear I am following
    "3. Now add one action : "Set Variable"
        Variable Name : CarId & Type : Integer
        Assign with CurrentItem's CarName (which one is lookup column for Car Name)"
    I am unable to assign the new variable to the ItemName. Nor do I get the option of a lookup for integer like shown in the example link.

  • Update Navigation Settings of a List automatically , NO manually

    Hi I tried to find a solution for this:
    I'm using the <b>Metadata Navigation settings </b> of Lists in SharePoint 2013. They are drop down menus\filters that sorts my lists.
    These menus are based on the values of <b>Choice Type columns</b> or <b>Metadata Columns</b>. My problem is that I want to update the values (filters) of these menus\filters automatically , without human intervention.
    This means: If there is a new type of choice\metadata in the column , I want that the drop down menu would be updated automatically and with <b>Choice Type columns</b> this is not possible or I couldn't figure it.
    I have to clarify that the insertion of the items in the lists is automatically with a tool called Layer2 so I can't insert values in a<b>Metadata Type column"</b>.
    Also,I tried to create a workflow that insert values in a "<b>Metadata Type column"</b> and then  <u><b>insert the metadata navigation menu\filter of the list based on this column</b></u>  BUT I check
    and looks like is not possible insert values in metadata columns though workflows.
    Does anybody knows how to update the "Metadata Navigation filters\menus" of a list automatically?
    I don't want add a new type of choice manually or new metadata manually.

    Hi,
    To update a column in one list based on another column, you have two options.  If it is a simple formula, then you can define the formula in the column definition as a calculated field.  If it is more complex than that, then you will have to write
    an EventHandler.  Whenever, a listitem is added or updated, the ItemAdded or ItemUpdated Event is raised.  You will get a handle to the listItem through which you should be able to get all the field values.  In this event, you can update the
    other column as you want.
    There is some reference here :
    http://koenvosters.wordpress.com/2009/07/31/howto-create-an-event-handler-for-sharepointmoss-2007/
    Regards
    Ranga
    Regards Ranga www.sharepointfrontier.com

  • Numbered lists in text boxes automatically updating

    I have seperate text boxes that are involved in numbered lists, and I want to be able to reorder the text boxes so that they automatically update the numbers within them. How do I do this?! As you can see when I move the text box containing 2.0 numbered list, the following numbers do not update. How do I create this updating numbered list in seperate text boxes?

    If you mean the text function in the drawing toolbar, it isn't possible.
    You should use frames.

  • When ever i click a picture in photo booth it does not automatically update its content is this a bug or i don't know how to do it?

    when ever i click a picture in photo booth it does not automatically update its content is this a bug or i don't know how to do it?
    whenever you click a picture in photobooth you have to manually insert it one by one in iphoto
    i want to know is there any other option in iphoto which can do this type of thing(adding pictures automatically to iphoto )
    so that i do not have to do it manually

    Once you take the photo with Photo Booth, select the photo in the tray at the bottom and click on the iPhoto button just abouve and to the left:
         Click to view full size
    That will import the photo into iPhoto automatically.  But PB does not import any and all photo taken into iPhoto automatically.  That choice is left to the user.
    OT

  • When ever i click a picture in photo booth it does not automatically update its content is this a bug ?

    when ever i click a picture in photo booth it does not automatically update its content is this a bug or i don't know how to do it?

    Once you take the photo with Photo Booth, select the photo in the tray at the bottom and click on the iPhoto button just abouve and to the left:
         Click to view full size
    That will import the photo into iPhoto automatically.  But PB does not import any and all photo taken into iPhoto automatically.  That choice is left to the user.
    OT

  • Binding arraylist, list, or multi-dimensional array to table in web dynpro

    Greetings,
    I like to ask if anyone knows how to bind data from an arraylist, list, or multi-dimensional array list to a table in web dynpro, your help is much appreciated.
    Thanks in advance.
    Cory

    Is there a way to create or cast a multi-dimensional
    array from a Collection or Vector ?
    ArrayList list = new ArrayList();
    list.add( new Object[4] );
    Object[] array2 = list.toArray(); // is only
    single dimension !
    Of course it is a single dimension array.
    Check the definition of the toArray() function, and the specification of arrays in general.
    toArray() returns a one dimensional array.
    In your case it will return an array of arrays. So array2[0] will be an array of 4 objects.
    That just happens to be a 2 dimensional array though you may (I haven't checked it) need some parentheses to call the elements.
    Try Object o = array2[0][1]; and if that doesn't work Object o = (array2[0])[1];

  • How to automatically update InfoPath Form fields(Design) when a new Column is created in SharePoint list?

    Hi All , 
    We have a scenario to automatically update the Infopath form(List Form) fields(Field Name and Control) when ever a new Column is created in the SharePoint list. Is it possible to do this? any options or suggestions?
    Thanks and Regards,
    Nandini

    Hi Nandini,
    I am not very sure will this be going to help you. Ideally, it's not so easy to communicate with infopath using object model. But still you can give it a try using below link :
    http://social.msdn.microsoft.com/forums/sharepoint/en-US/00125fdc-2115-47ea-8e8b-1ca9e5942f83/update-infopath-form-field-in-event-receiver
    I think the above solution is trying to update the field. Addition to that you can try creating a field and control.
    Let me know if it helps  !!
    Thanks

  • Content Types updates not getting pushed to Lists/Libraries Sharepoint 2013

    Hello,
    We have updated Content Type at Content Type Hub(ex. Making columns Hidden/Req...etc..). These changes are pushed to the consumer sites site level Content types but the problem is these changes are not reflecting at List/Library level Content type.
    Is there a way to explicitly push down the changes ?
    Best Regards, Pankaj Rana

    http://sharepoint.stackexchange.com/questions/52259/how-to-update-a-deployed-content-type
    perform the changes to the ContentType make sure to push changes to the lists while updating the ContentType.
    For now, you might need to perform some clean-up job here, just to make sure the field is deleted from all the lists, with your Custom ContentType. Use the following PowerShell script for clean-up! Vårsegod :)
    Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
    $site = Get-SPSite "http://your.site.com"
    foreach($web in $site.AllWebs)
    #iterates through all the Lists
    for ($i = 0; $i -lt $web.Lists.Count; $i++)
    $list = $web.Lists[$i];
    $MyListContentTypes = $list.ContentTypes
    if ($MyListContentTypes -ne $null)
    $ct = $list.ContentTypes["You Desired Content Type Name"]
    if($ct)
    Write-Host "In list Content Type and deleting the field" $ct.Fields["You Field Name"].Id;
    $ct.FieldLinks.Delete($ct.Fields["You Field Name"].Id)
    $ct.Update()
    Edit: How to push down changes to all the Content types via SharePoint Server Object Model:
    using (SPWeb oWebsite = new SPSite("http://MyServer/sites/MySiteCollection/MyWebSite").OpenWeb())
    SPList oList = oWebsite.GetList("MyWebSite/Lists/MyList");
    SPFieldCollection collFields = oWebsite.Fields;
    string strNewColumn = collFields.Add("MyNewColumn", SPFieldType.Text, false);
    SPFieldLink oFieldLink = new SPFieldLink(fields[strNewColumn]);
    SPContentType oContentType = oList.ContentTypes["Specification"];
    oContentType.FieldLinks.Add(oFieldLink);
    oContentType.Update(true);
    Edit 2: Update a Content Type using PowerShell:
    Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
    //get the specific Root web
    $spweb= Get-SPWeb "http://your.site.com"
    //get the fields collection
    $fields = $spWeb.Fields
    //get the specific field
    $field = $fields.GetFieldByInternalName("Name of you field")
    //get the specific Content Types from Root Web
    $contentType = $spWeb.ContentTypes["You Content Type"]
    //delete a field from a Content Type
    $contentType.FieldLinks.Delete($field)
    //add a field to a Content Type
    $contentType.FieldLinks.Add($field)
    //update the Content Type and push changes to the children
    $contentType.Update($true)http://sharepoint.stackexchange.com/questions/42744/how-to-add-a-field-to-a-contenttype-with-feature-upgrade-for-new-and-existing-shttp://msdn.microsoft.com/en-us/library/office/aa543504%28v=office.14%29.aspx
    If this helped you resolve your issue, please mark it Answered

  • Roxio Streamer is not automatically updating my Movie List...

    Since the Roxio Streamer is not automatically updating its movie list, I'm also not receiving email notifications when new movies are ready to be viewed remotely. How do I fix this problem?

    I'll wait for Roxio to answer this question...

  • HT5246 My computer won't let me select "automatically update safe downloads list"  What am I doing wrong?

    My computer won't let me select "automatically update safe downloads list"  What am I doing wrong?

    You are correct that is what I'm talking about.  I did install it. 
    Now I can't get the check box in the preferences security panel under the tab "general" that allows "automatically update safe downloads list" to stay checked.  Each time I unlock and check the box and then relock and close, the check mark disapears.  This is the problem.

  • HT3662 On my OS X v10.7.5 there is no "Automatically update safe downloads lists"

    On my OS X v10.7.5 there is no "Automatically update safe downloads lists" in the advanced security settings. There is however "Automatically install important security updates". I've ran every available update for my MAC, but the security features have not changed. How can I get this to update?

    http://support.apple.com/kb/HT1222

Maybe you are looking for

  • Mail constantly checks for new mail; downloads same emails repeatedly HELP!

    For the last three days (since 19th), Mail has been downloading the same emails over and over again. I first noticed a problem when about 20 spam emails that usually route to my Junk folder appeared in my Inbox. I thought I had just moved it incorrec

  • Can't edit in Photoshop CS5

    I just bought a new computer that uses Windows 7. I successfully restored my Elements Catalog. But when I click on a photo in the Organizer, then click on Edit, then on Edit with Photoshop, all that happens is I see a moving circle, then briefly an h

  • A sql tuning issue

    Hi, In a data warehousing env, version 11.1.0.7.0 on Redhat linux. run a query like below,select sum(case when T495255.PAYMENT_TYPE_ID = 3 then T495255.PAYMENT_ADJUSTMENT_AMOUNT end ) as c1, max(T494961.DATE_VALUE) as c2, sum(T495343.CURRENT_BALANCE_

  • Is there any tool monitoring messages in the pipeline?

    I wonder whether there is a tool which can tell the time each queue spends in each step of the pipeline? e.g. how much time a queue spent on client determination, on xml conversion, ... Thanks!

  • PSE 7: Is it possible to use VLC instead of Quicktime to play movies?

    Hi, I have VLC (VideoLAN)installed (using Vista). It plays my .mov video files. But PSE 7 still requests Quicktime to be installed. Isn't it possible to use VLC within PSE? Thanks. /Frank