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

[Solved] ScrollMode=Deferred - How to set the content of the scroll info?

2 Answers 477 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Pinho
Top achievements
Rank 1
Pinho asked on 28 Aug 2009, 01:30 PM
Hi,

 looking into your examples I see that you set the scroll info using templates, but it has too much information to realize what is strickly necessary.
The only thing that I want is to set the scroll info with the data that exists in the 2nd column (Name in my case) instead of the 1st.

<grid:RadGridView IsReadOnly="True" x:Name="gridEntitiesList" AutoGenerateColumns="True" ColumnsWidthMode="Fill"
                                        <grid:RadGridView.Template> 
                                            <ControlTemplate TargetType="grid:RadGridView"
                                                <gridControl:ScrollPositionIndicator> 
                                                <gridControl:ScrollPositionIndicator.Template> 
                                                    <ControlTemplate TargetType="gridControl:ScrollPositionIndicator"
                                                        <ContentPresenter Content="{Binding}"
                                                            <ContentPresenter.ContentTemplate> 
                                                                <DataTemplate> 
                                                                    <TextBlock Text="{Binding Data.Name}"></TextBlock> 
                                                                </DataTemplate> 
                                                            </ContentPresenter.ContentTemplate> 
                                                        </ContentPresenter> 
                                                    </ControlTemplate> 
                                                </gridControl:ScrollPositionIndicator.Template> 
                                            </gridControl:ScrollPositionIndicator> 
                                            </ControlTemplate>                                                 
                                        </grid:RadGridView.Template> 
                                    </grid:RadGridView> 

Could you point out what is missing here, nothing appear if I set this code...
Must I set a template for everything - rows, row headers, etc?

Thanks ahead for the replies.

L. Pinho

2 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 01 Sep 2009, 03:58 PM

Hello Luis,

In order to make this approach work you will have to set the complete template  with all the required elements as demonstrated in the example. You are absolutely right that this is a scary amount of XAML for such a 'cosmetic' change.

That is why we have decided to introduce a new convenience property of the RadGridView ScrollPositionIndicatorTemplate. It will be available in our very next oficial release.

Meanwhile I will suggest a lighter approach utilizing a few lines of code-behind  instead of the large XAML for the whole GridView.

You will have to subscribe to the loaded event of RadGridView and within the handler set the new binding as demonstrated in the extract bellow.

public MainPage()  
        {  
            InitializeComponent();  
            this.RadGridView1.Loaded += new RoutedEventHandler(RadGridView1_Loaded);  
            this.RadGridView1.ItemsSource = Person.GetSampleListOfPersons();  
              
              
        }  
 
        void RadGridView1_Loaded(object sender, RoutedEventArgs e)  
        {  
            Binding binding = new Binding("Data.FirstName");  
            this.RadGridView1.ApplyTemplate();  
            ScrollPositionIndicator indicator = this.RadGridView1.ChildrenOfType<ScrollPositionIndicator>().First();  
            indicator.ApplyTemplate();  
            ContentPresenter presenter = indicator.ChildrenOfType<ContentPresenter>().First();  
            presenter.SetBinding(ContentPresenter.ContentProperty, binding);  
              
        } 

Greetings,

Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Pinho
Top achievements
Rank 1
answered on 07 Sep 2009, 09:28 AM
Hi Pavel,

 thanks for the reply, I will try it and return the results to you.
Tags
GridView
Asked by
Pinho
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Pinho
Top achievements
Rank 1
Share this question
or