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

Focus indicator for row

3 Answers 294 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 28 Jun 2013, 08:30 PM
I'm using a GridView and would like to show a focus indicator for the entire row rather than a single cell.  Here's a sample of what I've tried:

XAML:
<Window x:Class="RadGridViewRowFocus.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <telerik:RadGridView ItemsSource="{Binding Items}"
                             SelectionUnit="FullRow"
                             IsReadOnly="True" />
    </Grid>
</Window>

Code Behind:
namespace RadGridViewRowFocus
{
    using System.Collections.ObjectModel;
    using System.Windows;
 
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
 
            DataContext = this;
            Items = new ObservableCollection<SampleData>
            {
                new SampleData { Field1 = "Item 1", Field2 = "Item 1, Field 2" },
                new SampleData { Field1 = "Item 2", Field2 = "Item 2, Field 2" },
                new SampleData { Field1 = "Item 3", Field2 = "Item 3, Field 2" },
                new SampleData { Field1 = "Item 4", Field2 = "Item 4, Field 2" }
            };
        }
 
        public ObservableCollection<SampleData> Items { get; set; }
    }
 
    public class SampleData
    {
        public string Field1 { get; set; }
        public string Field2 { get; set; }
    }
}

I'd like to get a dotted-line focus indicator around the entire row (excluding the row header), similar to an item in a list box.  I would have thought setting SelectionUnit="FullRow" would cause that to happen, but I still see a focus rectangle around the cell that is focused.  If there's a different control that would provide this along with columns, then I'm open to that too.

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 03 Jul 2013, 12:45 PM
Hello,

To achieve the required result, you could redefine the template for the GridViewRow and change the "Background_Selected" border to show focus indicator.

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Patrick
Top achievements
Rank 1
answered on 03 Jul 2013, 12:54 PM
As I understand the template, "Selected" is different than "Focused."  In other words, only one row will ever have focus, but I could have 10 selected at the same time.  Also, and correct me if I'm wrong, if I redefine the template then the row's style won't change when the system's theme changes.  508 compliance is the main concern here, and I need the focus indicator to appear while still respecting system themes such as high contrast.

Any additional help, resources, or code samples would be appreciated.
0
Dimitrina
Telerik team
answered on 03 Jul 2013, 03:29 PM
Hi,

Unfortunately there is not a Focused state for the GridViewRow. The states that I can suggest are Selected and Current. If you set IsSynchronizedWithCurrentItem="True", then the Current item will hold the first item you have selected (when multiple items are selected). As to drawing the border itself, you can check this forum thread on how you can do this.

As to your second question, yes, you are right. Please note that the styles are Theme's specific.

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Patrick
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Patrick
Top achievements
Rank 1
Share this question
or