Back to Devexpress

CRXPF0009 - AutoWidth and relative column width are used together

coderushforroslyn-403957-static-code-analysis-xaml-analyzers-crxpf-0009-auto-width-and-relative-column-width-are-used-together.md

latest1.8 KB
Original Source

CRXPF0009 - AutoWidth and relative column width are used together

  • Feb 14, 2023

Severity: Error

The analyzer detects that you use relative (star) values to specify a column’s Width property, and the TableView.AutoWidth or TreeListView.AutoWidth property is set to true. In this case, the GridControl does not apply relative column widths.

Examples

Invalid Code

xaml
<dxg:GridControl ...>
    <dxg:GridControl.View>
        <dxg:TableView AutoWidth="True" .../>
    </dxg:GridControl.View>
    <dxg:GridColumn FieldName="FieldName1" Width="3*"/>
    <dxg:GridColumn FieldName="FieldName2" Width="2*"/>
    <dxg:GridColumn FieldName="FieldName3" Width="*"/>
    <!-- ... -->
</dxg:GridControl>

Valid Code

xaml
<dxg:GridControl ...>
    <dxg:GridControl.View>
        <dxg:TableView AutoWidth="False" .../>
    </dxg:GridControl.View>
    <dxg:GridColumn FieldName="FieldName1" Width="3*"/>
    <dxg:GridColumn FieldName="FieldName2" Width="2*"/>
    <dxg:GridColumn FieldName="FieldName3" Width="*"/>
    <!-- ... -->
</dxg:GridControl>

How to Fix

Set the TableView.AutoWidth or TreeListView.AutoWidth property to false if you use relative (star) values to specify a column’s Width property.

Refer to the following help topic for more information: Resize Columns in Code.