Welcome to the Xceed Community | Help
Community Search  
More Search Options

How to bind to selected columns in Xceed WPF Grid?

Sort Posts: Previous Next
  •  06-12-2012, 11:49 PM Post no. 32246

    How to bind to selected columns in Xceed WPF Grid?

    How to bind to selected columns in Xceed WPF Grid?

    CurrentColumn is the only way I could find to get the selected column.  There is no other property on the grid for easy access.

    Also, how do we get multiple selected columns to ViewModel in MVVM.  Is there a way to get it without using code behind?

    Thanks in advance.

     

     

  •  06-14-2012, 10:46 PM Post no. 32256 in reply to 32246

    Re: How to bind to selected columns in Xceed WPF Grid?

    Hi Pritesh,

    In order to match the columns with the properties in your business object, you can do 2 things.

    1) Have them automatically generated.

         -> This will display every member from your business object

    2) Define the columns you want to display manually

         -> You have the choice to choose which columns gets displayed to the user

     

    If you choose option 1, then you can set the AutoCreateColumns property to true on the DataGridControl.

    If you choose option 2, then you will need to manually define your columns in XAML and provide the FieldName property. The FieldName property corresponds with the name of the members in your BusinessObject, such as: FirstName, LastName, Age, EyeColor, etc.Your XAML should look like this when define your columns:

    XAML

    ----------------

    <xcdg:DataGridControl Name="MyDGC" AutoCreateColumns="False" ItemScrollingBehavior="Immediate" Grid.Row="1"
                              ReadOnly="False" ItemsSource="{Binding Source={StaticResource MyPeopleCollectionCollectionView}}"
                                  >
                <xcdg:DataGridControl.Columns>
                    <xcdg:Column FieldName="FirstName" Title="Column1" />
                    <xcdg:Column FieldName="LastName" Title="Column2" />
                    <xcdg:Column FieldName="Age" Title="Column3" />
                    <xcdg:Column FieldName="EyeColor" Title="Column4" />
                    <xcdg:Column FieldName="BirthDate" Title="Column5" />
                    <xcdg:Column FieldName="Prefix" Title="Column6" />
                </xcdg:DataGridControl.Columns>
            </xcdg:DataGridControl>

    ----------------


    Marc

    Developer in Technical Support
    Xceed - Multi-talented components - http://xceed.com
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.