Skip to content

DevExpress-Examples/wpf-grid-scrollbar-annotations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WPF Grid – Display Scrollbar Annotations

This example introduces Scrollbar Annotations in the WPF GridControl. When the grid loads, its vertical scrollbar displays annotations that indicate the location of search results and selected cells. These visual markers allow users to quickly navigate to relevant data.

Display Scrollbar Annotations

Implementation Details

The example displays a side panel that lists annotation modes supported by the GridControl. When a user selects a mode, the bound ScrollBarAnnotationMode property updates accordingly:

<dxg:TableView x:Name="myView"  
               ScrollBarAnnotationMode="{Binding EditValue, ElementName=myListBoxEdit, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
               ScrollBarCustomRowAnnotation="MyScrollBarCustomRowAnnotationEventHandler" />

The GridControl can display annotations for the following items:

  • Focused and selected rows
  • Invalid rows and cells
  • Search results

To define additional annotations based on custom rules, handle the ScrollBarCustomRowAnnotation event. In this example, the event handler checks the Number property of a row’s data object and displays a custom annotation if the value falls within certain ranges:

void MyScrollBarCustomRowAnnotationEventHandler(object sender, ScrollBarCustomRowAnnotationEventArgs e) {
    if (e.Row is not TestData data) return;
    int number = data.Number;
    if (number > 10 && number < 15)
        ShowCustomScrollAnnotation(e, Brushes.LightCoral);
    if (number > 2 && number < 4)
        ShowCustomScrollAnnotation(e, Brushes.Green);
}

void ShowCustomScrollAnnotation(ScrollBarCustomRowAnnotationEventArgs e, SolidColorBrush brush) {
    e.ScrollBarAnnotationInfo = new ScrollBarAnnotationInfo() {
        Alignment = ScrollBarAnnotationAlignment.Right,
        Brush = brush,
        MinHeight = 3,
        Width = 10
    };
}

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Displays scrollbar annotations in the WPF Grid Control.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •