Fridolin Tam
Fridolin Tam

Reputation: 11

DataGrid Template example with xceed Datagrid Template

im new to the xceed datagrid and i tried to clone my code for my normal datagrid, but it won´t work with the xceed datagrid.
Here is my example:

<DataGrid Itemsource="{Binding Path=list}" AutoGenerateColumns="False">
  <DataGrid.Columns>
    <DataGridTextColumn Header="Name" Binding="{Binding Path=Name}"/>
  </DataGrid.Columns>
</DataGrid>

So, how does this work with the xceed datagrid?
Greetings

Upvotes: 0

Views: 4106

Answers (2)

Ravi Solanki
Ravi Solanki

Reputation: 309

first add the namespace

xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"

To use DatagridControl, you should try like this -

 <xcdg:DataGridControl ItemsSource="{Binding PersonList}" 
                          Margin="0,0,0,100"
                          ReadOnly="{Binding IsGridReadOnly}"
                          >

        <xcdg:DataGridControl.Columns >

            <xcdg:UnboundColumn FieldName="Id"  Visible="False"  />          

            <xcdg:Column FieldName="FirstName"
                            Width="*"
                            Visible="True"   />

            <xcdg:Column FieldName="LastName" 
                         Width="*"
                         Visible="True" />


        </xcdg:DataGridControl.Columns>

    </xcdg:DataGridControl>

In the ViewModel, Here i have

 private ObservableCollection<Person>  _PersonList ;

    public ObservableCollection<Person> PersonList
    {
        get { return _PersonList; }
        set { _PersonList = value; }
    }

In the constructor, i am calling LoadData Method to populate Person List. In Person class i have 3 fields - ID, FirstName and LastName.

Here in the datagrid, you can see there is 2 types of columns - column and unboundcolumn

Upvotes: 0

Diane-Xceed
Diane-Xceed

Reputation: 319

In the case of the Xceed DataGridControl, the ItemsSource is a DataGridCollectionView.

Here is a quick example:

<Window.Resources>
    <xcdg:DataGridCollectionViewSource x:Key="mySource" Source="{Binding Path=list}" />
</Window.Resources>

<Grid>
    <xcdg:DataGridControl ItemsSource="{Binding Source={StaticResource mySource}}" AutoCreateColumns="False">
        <xcdg:DataGridControl.Columns>
            <xcdg:Column FieldName="FirstName" Title="First Name" />
            <xcdg:Column FieldName="LastName" Title="Last Name" />
        </xcdg:DataGridControl.Columns>
    </xcdg:DataGridControl>
</Grid>

Upvotes: 2

Related Questions