Bind WPF grid to non-observable collection

Hello,
I have an object of MyClass, returned by business tier.
MyClass has a property of type List, say
class MyClass
public string Name;
public List<Whatever> Items;
I want to bind that collection of Items to grid in WPF screen with two-way updates using MVVM.
If I bind List<Whatever> via property, my grid does not reflect any changes to the underlying property b/c List does not support NotifyPropertyChanged.
I create a new Observable Collection from  List<Whatever>, bind it to grid and it works fine. But now I have 2 instances of the same data in memory, one as List<Whatever> and one as ObservableCollection<Whatever>.
Now, if I make changes to ObservableCollection via UI, it gets modified by framework, but I have to manually update List object with the same changes to keep them in sync, b/c after user is done with changes and wants to save modified MyClass, I need
to make sure MyClass.Items has all the user's changes.
My question is - isn't there a better way handle this situation than copying List to ObservableCollection and back?
Can I bind List property directly to Grid and still have two-way updates out of box? Any suggestions?
Thank you!
Isolda

Thanks for your replies. I did make public List<Whatever> Items into a property in my ViewModel, so that ViewModel looks like this
class MyViewModel : INotifyPropertyChanged
    private MyClass _myClass = new MyClass();
    public string Name { get { return _myCLass.Name; } set{ _myClass.Name = value; }}
    public List<Whatever> Items { get { return _myClass.Items; } set { _myClass.Items = value;}}
XAML is this
<telerik:RadGridView ItemsSource="{Binding Items, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=True, NotifyOnTargetUpdated=True}" />
Whenever I add items, I call NotifyPropertyChange("Items").
Grid does not reflect changes to the List, unless I do something to the grid, like click to Sort the column.
The second comment about changes to Whatever objects in the list - "Whatever" is a DTO object, really don't want to add any code to it... I think I'll just stick to copying from List to Observable collection and back, although I'm concerned
about 2 times more memory.
If I misunderstood your replies pls let me know what I'm missing.
Thanks.
Isolda

Similar Messages

  • Bug - View changes to grid when expanding a collection in the left pane.

    Tried submitting this via the bug report form but got java errors. Sigh...
    This seemed like the best alternative.
    ******BUG******
    Concise problem statement:
    View changes to grid when expanding a collection in the left pane.
    Steps to reproduce bug:
    1. Goto Library Module
    2. Ensure there is a collection with at least one child - if not create one.
    3. Make sure the collection is collapsed (you cant see the child and you see a right pointing triangle to the left of the collection name)
    4. Change to Loupe view
    5. Click the right pointing triangle next to the parent collection you just created to expand it.
    Actual Results:
    View changes to grid
    Expected results:
    View should remain unchanged - in this case Loupe view.

    The first is that I can't view the aperture library anymore directly from iphoto.
    THat is exceeding strange since iPhoto '08 could not open or share an Aperture library - that ability was first introduced in iPhoto '11 - with the latest version of iPhoto and or Aperture you can open the same library with either application - http://support.apple.com/kb/HT5043
    In the current version of iPhoto the photos are sorted by date in the film strip - I've not recently done a calendar so do not remember the specifics -
    LN

  • Non site collection admins unable to create publishing sites

    I've come across a problem which a number of other people have found and blogged about a 'fix', this is where non site collection administrators are unable to create sub sites with the publishing site templates (both with and without workflow version).
    The 'fix' for this is to grant 'Restricted Read' permission to everyone on the Masterpage and DeviceChannels folders.
    Does anyone know if this has been fixed properly, i.e. by Microsoft in one of the updates?  I'm still going through them one by one but haven't yet found one that sorts it out.
    Thanks.

    Hi Simon,
    I tested the same scenario per your post in my environment, and I cannot create the publishing site when I had no permission on the Device Channels list.
    It seems that we need to have at least Read permission on the Device Channels list (no permission is needed on the Master Pages Gallery ), then the publishing site can be created successfully.
    I checked the ULS log and found that the Device Channels list was needed to be requested when creating the publishing site. So if we have no permission on the Device Channels list, we cannot access the list and then the creation of the publishing
    site will fail.
    It is by design that Read permission is needed on the Device Channels list when creating the publishing site.
    Best regards.
    Victoria
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • "Your script uses objects from a non-existent collection"

    I have a multiple page form with a barcode on each form.  I created a separate collection for each barcode.  The auto generated code looks fine and has the correct collection created, however I still get the error, Paper Forms Barcode error "Your script uses objects from a non-existent collection".
    I'm not sure what is wrong and I don't know how to fix it.  Anyone else run into this?

    You will need to create a shared folder in Dropbox, then populate that with what ever folders you need to organize the files. It appears the DropBox app,will not handle this, but you can do, it by logging in to you account via Safari. Once the folders are created, they will show up in the app. Likewise with designating the folders as shared. Anyone you wish to share with will need a Dropbox account. (using the public folder will not work since links out it are for files only, not folders. An odd restriction, but it is what it is).
    IF you have copies of the files on a PC, you will find that will be the easiest place to upload them from. If they are only in iBooks on the iPad, you will need to synch and use the file management function to copy them off. not sure if you can synch them back over to DropCopy within iTunes (never tried it).
    DEpending on your needs, a couple of apps to look into are iCab Mobile (a browser), and GoodReader (doc viewing and management app). Both integrate well with DropBox.

  • Is it possible to bind the first element in a collection in a datagrid?

    I have a datagrid and I need to bind a property in the first element of the collection of my datasource object. By the momento I am using a converter:
    <DataGridTextColumn Header="MyValue" Binding="{Binding Converter={StaticResource myConverter}}"/>
    But I would like to avoid the need to use a converter, so I have tried this:
    <DataGridTextColumn Header="MyValue" Binding="{Binding MyCollectionProperty.ElementAt(0).MyValue}"/>
    Is there any way to do it?

    You cannot call ElementAt(i) from the XAML because it is a method.
    MyCollectionProperty[0] will certainly get you the first value of the MyCollectionProperty collection provided that the type has an indexer.
    If you want to be able to this without using a converter you must change the type of the property from ICollection<T> to for example IList<T>.
    You could create a wrapper property (potentially in a partial class definition) and bind to this one:
    //old property:
    public ICollection<YourType> MyCollectionProperty {
    get;
    set;
    //new wrapper:
    public IList<YourType> MyCollectionPropertyWrapper {
    get {
    return new List<YourType>(this.MyCollectionProperty);
    <DataGridTextColumn Header="MyValue" Binding="{Binding MyCollectionPropertyWrapper[0].MyValue}"/>
    ICollections are not very XAML friendly and you cannot bind to the first item of an ICollection using an indexer or ElementAt(0) or any other direct way.
    Please remember to mark all helpful posts as answer to close your threads.

  • How to share a non-copyrighted collection from ibooks

    I have 25 health education brochures that are non-copyrighted saved on a shelf in ibooks.  I would like to email them as a group to my work colleagues so they have acccess on their ipad but I can't figure out how to do this.  It allows me to send them individually but I want to keep them as a collection specific to diabetes. How can this be done?
    Thanks for your help

    You will need to create a shared folder in Dropbox, then populate that with what ever folders you need to organize the files. It appears the DropBox app,will not handle this, but you can do, it by logging in to you account via Safari. Once the folders are created, they will show up in the app. Likewise with designating the folders as shared. Anyone you wish to share with will need a Dropbox account. (using the public folder will not work since links out it are for files only, not folders. An odd restriction, but it is what it is).
    IF you have copies of the files on a PC, you will find that will be the easiest place to upload them from. If they are only in iBooks on the iPad, you will need to synch and use the file management function to copy them off. not sure if you can synch them back over to DropCopy within iTunes (never tried it).
    DEpending on your needs, a couple of apps to look into are iCab Mobile (a browser), and GoodReader (doc viewing and management app). Both integrate well with DropBox.

  • 11g Grid Control - Host Configuration Collection Problems

    Hi Guys,
    I just installed Oracle 11g Grid Control and it has been running for 2 weeks until I recently tried to walk through the parts of it.
    My intention was to clear off all the error messages, critical warnings, alerts, and policy warnings.
    When I arrived at the development summary box, on the home tab, I can see that there is 1 collection problem.
    When I clicked it, I saw that apparently the problem is with the host where I installed the grid control.
    Problem type: Warning during collection of Oracle Software
    message: Unknown WLS Home Location or WLS Version in Middleware Home /u01/app/oracle/product/middleware
    I tried clicking on the "Refresh Host" button, but it didn't solve the problem at all.
    I have also tried to take a look at the targets.xml however it seems the configuration in there are already pointing to the correct path to the weblogic home.
    Please let me know if anyone has a suggestion for this.
    Searching from google doesn't really return anything closely matched to this.
    Thanks,
    Adhika

    What is the intent/timeline for fixing this bug? On MOS, it appears to have a status of "Status 33 - Suspended, Req'd Info not Avail". We are encountering this bug also and I would glady provide information from our systems in order for the issue to be resolved.
    Thanks.
    PostScript: FWIW, Google yielded a blog referencing this error and Doc ID 1433113.1. I am unable to access that document (as was the blogger). Because of this, and another major caveat (our machines with this collection error do not have WLS installed on them), I'm thinking this probably needs to be an SR rather than a forum discussion.
    Edited by: JeriF on Feb 4, 2013 12:00 PM

  • Advance Data Grid - Flat Query Array Collection To Grouping Collection Issue

    Currently I have a Coldfusion CFC returning a flat query. The query is flat but returns data with four levels. For simplicity let's say Region, Territory, Title, and Person.
    I place the data into an Array Collection in Flex and then use the Advanced Data Grid (ADG) with a Grouping Collection to create a hierarchy of Region, Territory, Title. At the lowest level of the ADG I have the Person data and that data is summarized up to the Region node. The problem I am having is that sometimes I do not have any person data but have data at the Title level that can be summarized up to the Region node.
    For data where the Title does not have any Person information the Title node still can be expanded to show a blank Person row. How can I prevent blank Person rows from showing up while still maintaining the ability to properly show available Person rows?
    Would using an XML Collection accomplish this?

    Currently I have a Coldfusion CFC returning a flat query. The query is flat but returns data with four levels. For simplicity let's say Region, Territory, Title, and Person.
    I place the data into an Array Collection in Flex and then use the Advanced Data Grid (ADG) with a Grouping Collection to create a hierarchy of Region, Territory, Title. At the lowest level of the ADG I have the Person data and that data is summarized up to the Region node. The problem I am having is that sometimes I do not have any person data but have data at the Title level that can be summarized up to the Region node.
    For data where the Title does not have any Person information the Title node still can be expanded to show a blank Person row. How can I prevent blank Person rows from showing up while still maintaining the ability to properly show available Person rows?
    Would using an XML Collection accomplish this?

  • How could I initialize a CFC with data before binding a grid to it?

    Hi there,
    I am refactoring some very old ColdFusion code (ColdFusion 5,
    not done by me), and I'm considering replacing a huge and complex
    HTML table with a CFGrid.
    This HTML table is in an INCLUDE file and called from two
    places, each time it gets a CFQuery with the same name and columns,
    so the HTML table loop over it, but the (very complex) Queries are
    built differently.
    It would be a major hassle to "open up" the original queries
    and build them into the CFC that should supply the data for my
    CFGrid, so my idea is to wrap the original query into a QoQ, and
    use the QoQ to display and maybe filter the CFGrid.
    But my problem is, the CFC that I use to bind to the CFGrid
    has to somehow get the original CFQuery to base the QOQ upon, and I
    haven't found any way to pass the CFQuery to it! I tried to pass
    the CFQuery itself in the bind expression as:
    <cfgrid format="html" name="gridTravel" pagesize=25
    sort=true autoWidth=false
    height="565"
    colheaderbold="false" colheaderfont="Franklin Gothic Medium"
    colheaderfontsize="16"
    selectcolor="##b8ccfa" selectOnLoad=false
    striperows=true
    font="Arial" fontsize="12"
    "cfc:travel.getTravelList({cfgridpage},{cfgridpagesize},
    {cfgridsortcolumn},{cfgridsortdirection},#TravelQuery# )">
    And I also tried to first initialize the CFC with the CFQuery
    before the binding:
    <cfscript>
    travelCfc = createObject("component", "travel");
    travelCfc.travelListBase = TravelSel;
    </cfscript>
    But nothing works.
    My question, does the binding of CFGrid to a CFC only works
    in a "static" way (in Java term)?! In that case, the initialization
    method would clearly never work properly, is it then possible to
    pass the CFQuery in the Bind at all?
    Given my requirement, what would be the best way of achieving
    what I'm doing?
    Any suggestion will be appreciated, and many thanks in
    advance.
    Billy

    If you go to the VI Properties, under the Execution menu selection there is a pop-up for setting the Preferred Execution System. This is as close as you can specifying a thread in LV.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • SCCM 2012 How create a non-compliant collection for Compliance Baseline settings

    In 2007 sccm I have the option to create a colecion for computers that non-compliance with the configuration of DCM.
    How I can create a colecion based on whether the computer is compliance or non-compliance with the compliance settings?

    You can still do this in CM12. Navigate to the Baseline deployment, select the deployment and look at the Ribbon or right click the deployment.
    Kent Agerlund | My blogs: blog.coretech.dk/kea and
    SCUG.dk/ | Twitter:
    @Agerlund | Linkedin: Kent Agerlund

  • A Question on WPF Grid - Grid.Column="x"

    I have a grid with 2 column.  In order to put elements into 2nd column I need to specify Grid.Column in all elements like below.
    <Label Grid.Column="1" Content="Specify Resource File and Folder" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top"/>                       
    <Label  Grid.Column="1" Content="File:" HorizontalAlignment="Left" Margin="29,74,0,0" VerticalAlignment="Top"/>
    Instead Can't I specify it this way ?  so that I have to change position, I just need to shift elements into different section.
    eg.
    <Grid.Column =1>
    <Label Content="Specify Resource File and Folder" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top"/>
    <Label Content="File:" HorizontalAlignment="Left" Margin="29,74,0,0" VerticalAlignment="Top"/>
    </Grid.Column>

    >>Instead Can't I specify it this way ?  so that I have to change position, I just need to shift elements into different section.
    Short answer: No, you cannot.
    Setting the Grid.Column and Grid.Row attached properties of an element is the only way to specify in which particular cell of the Grid that the element will be located.
    In XAML there are no cell or row elements in which you can put an element directly (like in HTML for example).
    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question.

  • Binding ALV GRID with Deep Internal Table

    Hello all,
    I am looking for a way to display ALV Grid with the Deep ITAB.
    My ITAB is not too complex.
    It has One Structure which gets whole DB table + One extra field.
    Therefore my Itab looks as follows.
    TYPES: BEGIN OF TY_TRIP,
            ZPM_UPLOAD LIKE ZDBTABLE, "ZDBTABLE is custom database table.
            TDTIME TYPE STRING,
           END OF TY_TRIP.
    DATA: ITAB TYPE TABLE OF TY_TRIP,
          WA_ITAB LIKE LINE OF ITAB.
    Now i am able to populate data into Deep ITAB.
    If i call ALV Grid with ITAB then i get error. So how to call 'REUSE_ALV_GRID_DISPLAY' with this ITAB?
    Thanks in advance.

    Hello,
    My senior asked me to use the below definition.
    TYPES: BEGIN OF TY_TRIP.
            INCLUDE STRUCTURE ZDBTABLE.
    TYPES:  TDTIME TYPE STRING,
           END OF TY_TRIP.
    DATA: ITAB TYPE TABLE OF TY_TRIP,
          WA_ITAB LIKE LINE OF ITAB.
    If anyone else is looking to print in ALV, they can use this type of ITAB definition though it gives you the flexiblity to create ITAB and also making it FLAT and not DEEP.
    But i am still looking for an answer for my first post.
    Thanks.

  • Just in case any one needs a Observable Collection that deals with large data sets, and supports FULL EDITING...

    the VirtualizingObservableCollection does the following:
    Implements the same interfaces and methods as ObservableCollection<T> so you can use it anywhere you’d use an ObservableCollection<T> – no need to change any of your existing controls.
    Supports true multi-user read/write without resets (maximizing performance for large-scale concurrency scenarios).
    Manages memory on its own so it never runs out of memory, no matter how large the data set is (especially important for mobile devices).
    Natively works asynchronously – great for slow network connections and occasionally-connected models.
    Works great out of the box, but is flexible and extendable enough to customize for your needs.
    Has a data access performance curve so good it’s just as fast as the regular ObservableCollection – the cost of using it is negligible.
    Works in any .NET project because it’s implemented in a Portable Code Library (PCL).
    The latest package can be found on nugget. Install-Package VirtualizingObservableCollection. The source is on github. 

    Good job, thank you for sharing
    Best Regards,
    Please remember to mark the replies as answers if they help

  • Running BIND (DNS) as a non-root user

    On Mac OS X Server 10.3.x the named daemon runs as root. I would like to change this so that named runs as a user (with out a shell). On other flavors of Unix, this typically involves using the "-u" flag when starting named. However, I am still getting familiar with the Mac command line, and how system daemons are started.
    XServe G5 Mac OS X (10.3.9)

    System services are handled by launchd.
    If you look in /System/Library/LaunchDaemons/ you'll see a plist file for each service including org.isc.named.plist, the plist for named.
    If you edit this file you'll see it's an XML document that describes the service and how the OS should handle it, including the part:
    <key>ProgramArguments</key>
    <array>
    <string>/usr/sbin/named</string>
    <string>-f</string>
    </array>
    Just append another entry in the array that says <string>-u nobody</string> (or whatever username you want to run as.

  • Binding the grid Dynamically

    aspx code::
    <dx:ASPxGridView ID="gridEstimate" runat="server"
                                        KeyFieldName="Tech_EstimateId"
                                        Width="99%" AutoGenerateColumns="false"
    >
                                            <Settings ShowHeaderFilterButton="true"
                                             EnableFilterControlPopupMenuScrolling="True"
                                             ShowFilterBar="Visible"
    ShowFilterRow="True" ShowFilterRowMenu="True"
    ShowFooter="True" VerticalScrollableHeight="350" />
    </dx:ASPxGridView>
    C# Code ::
    gridEstimate.DataSource = _busiobj.LoadDatavaluestoGrid(Convert.ToInt32(cmbCategory.Value));
    gridEstimate.DataBind();

    I'd ask them over here.
    Microsoft ASP.NET Forums 
    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

Maybe you are looking for

  • How can I stream my iTunes library to my iPhone or iPad?

    How can I stream my iTunes library to my iPhone or iPad?

  • Create a defaut view for the MS Project Server 2010 client

    Dear Forum, how can I create a defaut view for the MS Project Server 2010 client? I saved a template and set a default view under File -> Options ->Project View. I also did the same in the checked-out enterprise global. If I then close the client and

  • Flash Player 11_8_800_94 on Terminal Server

    Hi I have a problem with the newest Version of Flash Player on a Windows Server 2008 R2 Terminal Server. I have installed Flash as Administrator with "change user /install". Everything works fine as Administrator but as a normal User with User Rights

  • Site error only on my G5 iMac

    I previously posted this question and am still missing something. I'm reposting in hopes someone can further explain to me what the problem is. This is the original topic: http://discussions.apple.com/thread.jspa?threadID=771703&tstart=150 I created

  • Will an iPad restore / new setup kill my AT&T Unlimited Data plan?

    Hi guys, I'm going to be giving a presentation on the iPad's features to a business group I work with. Before giving the presentation, I'd like to fully restore my 64g+3G iPad and create a temporary "stock" profile - that way, I won't be presenting a