setting Column width of XamDataGrid in XAML

Saghar picture Saghar · Nov 5, 2010 · Viewed 9k times · Source

I want to set the Column width of XamDataGrid in XAML. There is no Width Property available like

<ip:Field Label="Name" ........... Width="60"/>

Here is my sample code.

    <ip:XamDataGrid Name="PatientsList" DataSource="{Binding PatientsList}" SelectedItemsChanged="PatientsListSelectedItemsChanged"
                    XamDataGridBehaviours:XamDataGridBehavior.IsSynchronizedWithCurrentItem="True" GroupByAreaLocation="None">
        <ip:XamDataGrid.FieldLayoutSettings>
            <ip:FieldLayoutSettings AutoGenerateFields="False" SelectionTypeRecord="Extended" MaxSelectedRecords="1"/>
        </ip:XamDataGrid.FieldLayoutSettings>
        <ip:XamDataGrid.FieldSettings>
            <ip:FieldSettings AllowEdit="False" CellClickAction="SelectRecord"/>
        </ip:XamDataGrid.FieldSettings>
        <ip:XamDataGrid.FieldLayouts>
            <ip:FieldLayout>
                <ip:FieldLayout.Fields>
                    <ip:Field Label="{Binding Source={x:Static properties:Resources.StudyManager_colSex}}" Name="Sex"/>
                    <ip:Field Label="{Binding Source={x:Static properties:Resources.StudyManager_colPatientId}}" Name="PatientId"/>
                    <ip:Field Label="{Binding Source={x:Static properties:Resources.StudyManager_colLastName}}" Name="LastName" />
                    <ip:Field Label="{Binding Source={x:Static properties:Resources.StudyManager_colFirstName}}" Name="FirstName" />
                    <ip:Field Label="{Binding Source={x:Static properties:Resources.StudyManager_colPatientId}}" Name="FullName" />
                    <ip:Field Label="{Binding Source={x:Static properties:Resources.StudyManager_colDOB}}" Name="DateOfBirth" />
                </ip:FieldLayout.Fields>
            </ip:FieldLayout>
        </ip:XamDataGrid.FieldLayouts>
    </ip:XamDataGrid>

Answer

Mike Dour picture Mike Dour · Nov 5, 2010

A Width property was added to Fields in version 9.2. But there have always been CellWidth, CellMinWidth, and CellMaxWidth properties on the FieldSettings and each field has its own FieldSettings.