This is a migrated thread and some comments may be shown as answers.

How to Fix the GridView width

2 Answers 755 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tae Hoon
Top achievements
Rank 1
Tae Hoon asked on 30 May 2017, 06:31 AM

I am trying to make some gridview pannel.

I want to make fixed GridView width in the windows. like p1.png. but it can'not be stretched dynamically.

bacause p1.png is made as fixing width in the xaml code (like grid Width="1200" in grid, and my original window width is also 1200). but i don't want to fix width like this.

so i change the code like Width="*" in grid. then gridview pannel can be p2.png.

It shift all panel in window. I don't want it.

How to make fixed gridview Width on the window and can be dynamically stretched.

 

--my code

<Grid HorizontalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        
        <telerik:RadGridView Name="tradeListPanel" AutoGenerateColumns="False" ItemsSource="{Binding tradeList}" ShowSearchPanel="True" FrozenColumnCount="7"
                             IsReadOnly="True" EnableRowVirtualization="False" EnableColumnVirtualization="False"
                             FontSize="12" telerikControls:StyleManager.Theme="Summer"
                             ShowColumnFooters ="True" RowIndicatorVisibility ="Collapsed"
                             IsSynchronizedWithCurrentItem ="True" RowDetailsVisibilityMode="VisibleWhenSelected" 
                             Margin="0,0,0,0" Padding="0,0,0,0">

            <telerik:RadContextMenu.ContextMenu>
                <telerik:RadContextMenu x:Name="GridContextMenu" 
                                    ItemContainerStyle="{StaticResource MenuItemContainerStyle}"
                                    Opened="GridContextMenu_Opened"
                                    ItemClick="GridContextMenu_ItemClick"
                                    />
            </telerik:RadContextMenu.ContextMenu>

            <telerik:RadGridView.ControlPanelItems>
                <telerik:ControlPanelItem ButtonTooltip="Column chooser">
                    <telerik:ControlPanelItem.Content >
                        <ListBox ItemsSource="{Binding Columns}" BorderThickness="0">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <CheckBox Content="{Binding Header, Mode=OneWay}" IsChecked="{Binding IsVisible, Mode=TwoWay}" />
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </telerik:ControlPanelItem.Content>

.................

................

</telerik:RadGridView>
    </Grid>

 

Thank you.

 

 

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
Tae Hoon
Top achievements
Rank 1
answered on 30 May 2017, 07:05 AM
meaning of the stretch is not change of the control size. if window size is changed by drag, it can be visible more Columns. and the control panel button have to shift by changing window size. 
0
Dilyan Traykov
Telerik team
answered on 01 Jun 2017, 12:59 PM
Hello Tae,

I already responded to the support ticket you opened. For completeness, I'm posting the reply here as well.

"I'm uncertain whether I understood your exact requirements, however, if you want RadGridView to stretch to the Width of its parent window, you will need to work with its column's widths. At least one of the columns should have its Width set to *.

Do bear in mind, however, that if the sum of the combined widths of all the columns is larger than that of the parent window, the control is bound to overflow.

If you do not find these suggestions relevant, please send over a small sample project along with a short description of the undesired behavior so that I can better assist you."

May I kindly ask you to continue the communication in only one of the two threads so that we can keep the conversation history intact? Thank you in advance for your cooperation and understanding.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Tae Hoon
Top achievements
Rank 1
Answers by
Tae Hoon
Top achievements
Rank 1
Dilyan Traykov
Telerik team
Share this question
or