Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
900
xamDataGrid with Hierarchical Data: Manually reducing Column Width
posted

Hi,

Manually reducing Column Width is not working for Hierarchical Data. Column width expansion(manual) works fine after setting Max Width. but reducing with is not working even after setting Min width. Here is my C# code and xaml code:

private Field CreateField(GridColumn gridColumn, Style styleVerticalLines)
{

Field fld = new Field();
fld.Name = gridColumn.Column.ColumnName;
fld.Label = gridColumn.Column.HeaderText;

FieldSettings _fieldSettings = new FieldSettings();

_fieldSettings.CellMinWidth = 10;
_fieldSettings.LabelMinWidth = 10;
_fieldSettings.Width = new FieldLength(width);
_fieldSettings.CellMaxWidth = maxWidth;
_fieldSettings.LabelMaxWidth = maxWidth;

_fieldSettings.CellValuePresenterStyle = styleVerticalLines;

fld.Settings = _fieldSettings;

return fld;
}

 

        <Style TargetType="{x:Type ig:CellValuePresenter}" x:Key="StyleVerticalLines">
            <Setter Property="BorderBrush" Value="LightGray"/>
            <Setter Property="BorderThickness" Value="0,0,1,0"/>           
            <Setter Property="Margin" Value="0,0,0,0" />
           
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />

     <Setter Property="ContentTemplate" >
                <Setter.Value>
                    <DataTemplate>
                        <Grid Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type ig:CellValuePresenter}},Path=Width}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <TextBlock Grid.Column="0" Text="!" Foreground="Red" HorizontalAlignment="Left" />

                            <TextBlock FontWeight="Bold" Grid.Column="1" HorizontalAlignment="Right"  Text="{Binding RelativeSource={RelativeSource

AncestorType={x:Type ig:CellValuePresenter}},Path=Value}" />
                        </Grid>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>

Thanks,

Shakti