Home Forums WPF controls Xceed DataGrid for WPF Fit column widths to grid like Outlook 2007

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #24568 |

    In the grid used by Outlook 2007, the columns always use the full width of the grid; there’s not even any way to see a horizontal scroll bar. As the grid is resized, the columns are proportionally resized to fit. If a column is resized by the user, the other columns are made smaller to make room.

    This would be an outstanding feature for the DataGrid.

    Imported from legacy forums. Posted by Ed (had 1091 views)

    User (Old forums)
    Member
    Post count: 23064

    To do something like this, it would be nice if we can specify width of columns using “*” unit as well as “Auto”.

    Imported from legacy forums. Posted by nat (had 298 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi,

    I think it is a missing functionality. Any news on when this will be available Xceed Team??

    Imported from legacy forums. Posted by Hadi (had 373 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi,
    I also need the auto column resizing feature.
    Thanks.

    Imported from legacy forums. Posted by Reyn (had 478 views)

    Xceed Support
    Member
    Post count: 5658

    Hi everybody,

    The “last column auto sizing” is already on our feature request list…

    Seeing the amount of “requests” for the feature definitely help us prioritize features for our next deliveries.

    Thank you all for your feedback.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 240 views)

    User (Old forums)
    Member
    Post count: 23064

    As a work around until then, to have the last column fit the remaining width this works for me.

    assuming you have a xmlns for the grid defined like this

    xmlns:p=”http://schemas.xceed.com/wpf/xaml/datagrid”

    Add these two styles to the Grids resources section

    <p:DataGridControl.Resources>
    <Style TargetType=”{x:Type p:ColumnManagerRow}”>
    <Setter Property=”Width” Value=”{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=ScrollContentPresenter}, Path=ActualWidth}”/>
    <Setter Property=”Template”>
    <Setter.Value>
    <ControlTemplate TargetType=”{x:Type p:ColumnManagerRow}”>
    <Grid x:Name=”rootGrid”>
    <Border x:Name=”rootBorder” Background=”{TemplateBinding Background}”/>
    <DockPanel LastChildFill=”True” x:Name=”PART_CellsHost”/>
    </Grid>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>

    <Style TargetType=”{x:Type p:DataRow}”>
    <Setter Property=”Width” Value=”{Binding RelativeSource={RelativeSource FindAncestor,AncestorType=ScrollContentPresenter},Path=ActualWidth}”/>
    <Setter Property=”Template”>
    <Setter.Value>
    <ControlTemplate TargetType=”{x:Type p:DataRow}”>
    <Grid x:Name=”rootGrid”>
    <Border x:Name=”rootBorder” Background=”{TemplateBinding Background}”/>
    <DockPanel LastChildFill=”True” x:Name=”PART_CellsHost”/>
    </Grid>

    <ControlTemplate.Triggers>
    <MultiDataTrigger>
    <MultiDataTrigger.Conditions>
    <Condition Binding=”{Binding RelativeSource={RelativeSource Self},Path=IsSelected}” Value=”True”/>
    <Condition Binding=”{Binding RelativeSource={RelativeSource FindAncestor,AncestorType=p:DataGridControl},Path=IsKeyboardFocusWithin}” Value=”True”/>
    </MultiDataTrigger.Conditions>

    <Setter TargetName=”rootBorder” Property=”Background” Value=”{Binding RelativeSource={RelativeSource TemplatedParent},Path=SelectionBackground}” />
    </MultiDataTrigger>
    <MultiDataTrigger>
    <MultiDataTrigger.Conditions>
    <Condition Binding=”{Binding RelativeSource={RelativeSource Self},Path=IsSelected}” Value=”True”/>
    <Condition Binding=”{Binding RelativeSource={RelativeSource FindAncestor,AncestorType=p:DataGridControl},Path=IsKeyboardFocusWithin}” Value=”False”/>
    <Condition Binding=”{Binding RelativeSource={RelativeSource FindAncestor,AncestorType=p:DataGridControl},Path=HideSelection}” Value=”False” />
    </MultiDataTrigger.Conditions>

    <Setter TargetName=”rootBorder” Property=”Background” Value=”{Binding RelativeSource={RelativeSource TemplatedParent},Path=InactiveSelectionBackground}” />
    </MultiDataTrigger>
    </ControlTemplate.Triggers>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>
    </p:DataGridControl.Resources>

    hope it helps…

    Imported from legacy forums. Posted by Alan (had 642 views)

    User (Old forums)
    Member
    Post count: 23064

    forgot to mention this step, you will need to set the last column’s width to NaN, ommiting it causes some strange behaviour and setting it to a static width obviously won’t work.

    Imported from legacy forums. Posted by Alan (had 5524 views)

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.