Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 94857

Scroll to row when programmatically setting selected item

$
0
0

Based on Erik's post, here is another attempt..

public class RadGridViewScrollIntoViewBehavior: Behavior<RadGridView>
    {
        private RadGridView Grid
        {
            get { return AssociatedObject; }
        }
 
        protected override void OnAttached()
        {
            base.OnAttached();
            Grid.Items.CollectionChanged += Items_CollectionChanged;
        }
 
        private void Items_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                var myRow = e.NewItems[0] as MyClassType;
                if (labelSet != null)
                {
                    Grid.ScrollIntoView(myRow );
                }
            }
        }
    }

In the RadGridView,

<telerik:RadGridViewItemsSource="{Binding MyItems}">
      <i:Interaction.Behaviors>
            <Utils:RadGridScrollIntoViewBehavior/>
      </i:Interaction.Behaviors>
</telerik:RadGridView>

 

Thanks


Viewing all articles
Browse latest Browse all 94857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>