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
250
XamGrid GroupColumn Sizing
posted

Hi,

In my grid I've defined three XamGrid GroupColumns, each containing an arbitrary set of TextColumns.  I want GroupColumn 1 to have 'star' width, GroupColumn 2 to have a fixed pixel width, and GroupColumn 3 to have 'star' width also.  These three GroupColumns must always span the full width of the host window.  Within each GroupColumn I want the text columns to autofit to fill the available space.   Here's my attempt to achieve this:

<ig:XamGrid ItemsSource="{Binding OptionsView}"
                    AutoGenerateColumns="False"
                    IsAlternateRowsEnabled="True">
    <ig:XamGrid.Columns>
        <ig:GroupColumn Key="Call"
                                Width="1*">
            <ig:GroupColumn.Columns>
                <ig:TextColumn Key="C_Bid"
                                       HeaderText="Bid"/>
                <ig:TextColumn Key="C_Ask"
                                       HeaderText="Ask" />
            </ig:GroupColumn.Columns>
        </ig:GroupColumn>

        <ig:GroupColumn Key="StrikeGrp"
                                HeaderText="Strike"
                                Width="150">
            <ig:GroupColumn.Columns>
                <ig:TextColumn Key="Strike"
                                       Width="150" />
            </ig:GroupColumn.Columns>
        </ig:GroupColumn>

        <ig:GroupColumn Key="Put"
                                Width="1*">
            <ig:GroupColumn.Columns>
                <ig:TextColumn Key="P_Bid"
                                       HeaderText="Bid"/>
                <ig:TextColumn Key="P_Ask"
                                       HeaderText="Ask" />
            </ig:GroupColumn.Columns>
        </ig:GroupColumn>

    </ig:XamGrid.Columns>
</ig:XamGrid>

Unfortunately, setting a GroupColumn's Width property has no discernable effect on the layout.  Can someone tell me how I can achieve the above objective?

Many thanks,
James

Parents
  • 34510
    Offline posted

    Hi James,

    The GroupColumn width is determined strictly by the widths of all the columns it contains.  To get the effect you're looking for you need to modify the individual column widths in each group.  This can't be done in XAML though since the columns are isolated from one another.  This means "1*" isn't going to work quite the way you need it.  You'll need to handle this in code behind.  I've attached a sample that should do the trick for your specific column layout.

    xamGrid-GroupColumnWidths.zip
Reply Children
No Data