When trying to change the Row height through Bindings in XamDatagrid. For CellHeight property of FieldSettings, The UI is not updating

Not Answered This post has 0 verified answers | 1 Reply | 2 Followers Thread's RSS feed.

Bhargavi
Points 20
Replied On: Wed, Oct 11 2017 5:44 PM Reply

I am trying to change the Row height through Bindings in XamDatagrid.
For CellHeight property of FieldSettings, When I hardcode the value like 15 or 0.1, It works. I would like to assign this value dynamically through property binding, Which is RowHeight in this case, the value is not getting reflected.
Basically I have a Button, when I click on that button, the RowHeight should toggle from 15 to 0.1 viceversa.
 <igDP:XamDataGrid.FieldLayoutSettings>
                            <igDP:FieldLayoutSettings HighlightAlternateRecords="True" AutoGenerateFields="False" AutoArrangeCells="Default"  SelectionTypeCell="None"
                                                      SelectionTypeField="Extended" SelectionTypeRecord="Single"  HeaderLabelAreaStyle="{StaticResource HeaderLabelAreaStyle}"
                                                      HeaderPrefixAreaDisplayMode="FieldChooserButton"/>
                        </igDP:XamDataGrid.FieldLayoutSettings>
                        <igDP:XamDataGrid.FieldSettings>
                            <igDP:FieldSettings AllowEdit="False" CellHeight="{Binding RowHeight,Mode=TwoWay}"  Width="Auto" CellClickAction="SelectRecord"  LabelTextAlignment="Center" LabelPresenterStyle="{StaticResource HeaderStyle}"/>
                        </igDP:XamDataGrid.FieldSettings>
                        <igDP:XamDataGrid.FieldLayouts>
                            <igDP:FieldLayout Key="ActiveLayout">
                                <igDP:UnboundField Height="{Binding RowHeight,Mode=TwoWay}" Width="20">
                                    <igDP:Field.Settings>
                                        <igDP:FieldSettings AllowEdit="False" AllowFixing="No" AllowGroupBy="False" AllowHiding="Never"
                                                            AllowRecordFiltering="False" AllowResize="False" AllowSummaries="False"
                                                            CellValuePresenterStyle="{StaticResource CompleteStopStyle}" />
                                    </igDP:Field.Settings>
                                </igDP:UnboundField>
                                <igDP:Field Name="Odo" Label="ODO"/>
                                <igDP:Field Name="StopTypeDisplay" Label="Typ"/>
                                <igDP:UnboundField BindingPath="Address.Street" Label="Street" Width="100"/>
                                <igDP:Field Name="UowCount" Label="#"/>
                                <igDP:Field Name="EsstDisplay" Label="Esst"/>
                                <igDP:Field Name="LsstDisplay" Label="Lsst"/>
                                <igDP:Field Name="RouteEsstDisplay" Label="ETA"/>
                                <igDP:Field Name="AdjustedSvcTimeDisp" Label="ASvc"/>
                                <igDP:Field Name="BulkOrder" Label="Bulk Order" Visibility="Collapsed"/>
                                <igDP:Field Name="CellId" Label="Cell ID" Visibility="Collapsed"/>
                                <igDP:Field Name="CellOrder" Label="Cell Order" Visibility="Collapsed"/>
                                <igDP:UnboundField Name="City" BindingPath="Address.City" Visibility="Collapsed"/>
                                <igDP:Field Name="CumulativeMiles" Label="*** Miles" Visibility="Collapsed"/>
                                <igDP:Field Name="CumulativeWaitTime" Label="*** WTime" Visibility="Collapsed"/>
                                <igDP:Field Name="DeliveryOrder" Label="Delivery Order" Visibility="Collapsed"/>
                                <igDP:Field Name="Feasible" Visibility="Collapsed"/>
                                <igDP:Field Name="GeoDelOrder" Label="Geo Delivery Order" Visibility="Collapsed"/>
                                <igDP:Field Name="GroupId" Label="Group ID" Visibility="Collapsed"/>
                                <igDP:Field Name="IsCompleted" Label="Completed" Visibility="Collapsed"/>
                                <igDP:Field Name="IsLastAirCandidate" Label="Last Air" Visibility="Collapsed"/>
                                <igDP:Field Name="LoopId" Label="Loop ID" Visibility="Collapsed"/>
                                <igDP:Field Name="Lsst1Display" Label="Lsst1" Visibility="Collapsed"/>
                                <igDP:Field Name="Lsst1PenaltyWt" Label="Penalty Weight" Visibility="Collapsed"/>

Is there any way to accomplish this?

  • Post Points: 20

All Replies

Nick
Points 1,840
Infragistics Employee
Replied On: Thu, Oct 12 2017 8:54 AM Reply

Hello Bhargavi,

Thank you for the code you have provided.

The FieldSettings element is not part of the visual tree, so it doesn't inherit the DataContext. You can however declare your ViewModel as a StaticResource.
For example:

<igDP:XamDataGrid.FieldSettings>
                <igDP:FieldSettings AllowEdit="False" CellHeight="{Binding RowHeight, Source={StaticResource vm}}"
   Width="Auto" CellClickAction="SelectRecord"  LabelTextAlignment="Center"/>
 </igDP:XamDataGrid.FieldSettings>

Using this approach I have created a small sample application

You can find also more information here.

Sincerely,
Nick
Entry-Level Software Developer

  • Post Points: 5
Page 1 of 1 (2 items) | RSS