Is there a way to automatically set the focus on the grid menu filter drop down to be the search text box so the user does not have to open the filter menu drop down and then click in the search box?
Hi Andrew,
I tried out your example and it works, however, it is a lot of maintenance to retrofit this into our exiting window code, so I have been trying to extend the XamGrid class so I only have to change/use a top-level control type to automatically get this feature. I am not having a lot of success, can you modify your example to work similar to what I have below?
<ig:XamGrid x:Class="InfragisticsEx.XamGridCustomFilterSelectionControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ig="http://schemas.infragistics.com/xaml" xmlns:igPrim="http://schemas.infragistics.com/xaml/primitives" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignHeight="145" d:DesignWidth="1000"> <ig:XamGrid.Resources> <Style TargetType="{x:Type igPrim:FilterSelectionControl}"> <EventSetter Event="Loaded" Handler="FCS_Loaded"/> </Style> </ig:XamGrid.Resources> </ig:XamGrid>
using System; using System.Windows; using System.Windows.Threading; using Infragistics.Controls.Grids; using Infragistics.Controls.Grids.Primitives; namespace InfragisticsEx { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class XamGridCustomFilterSelectionControl : XamGrid { void FCS_Loaded(object sender, RoutedEventArgs e) { FilterSelectionControl FCS = sender as FilterSelectionControl; FilterTextBox TB = Infragistics.Windows.Utilities.GetDescendantFromName((DependencyObject)FCS, "FilterTextBox") as FilterTextBox; if (TB != null) { Dispatcher.BeginInvoke(new Action(() => { TB.Focus(); }), DispatcherPriority.Background); } } } }
and then I try to use it like:
xmlns:InfragisticsEx="clr-namespace:InfragisticsEx;assembly=Utilities"
...
<InfragisticsEx:XamGridCustomFilterSelectionControl Grid.Row="1" x:Name="resultsGrid" AutoGenerateColumns="False"> <ig:XamGrid.ClipboardSettings> <ig:ClipboardSettings AllowCopy="True" CopyType="SelectedCells" CopyOptions="ExcludeHeaders" /> </ig:XamGrid.ClipboardSettings> <ig:XamGrid.SelectionSettings> <ig:SelectionSettings CellSelection="Multiple" /> </ig:XamGrid.SelectionSettings> <ig:XamGrid.SortingSettings> <ig:SortingSettings AllowMultipleColumnSorting="True" /> </ig:XamGrid.SortingSettings> <ig:XamGrid.FixedColumnSettings> <ig:FixedColumnSettings AllowFixedColumns="Both"/> </ig:XamGrid.FixedColumnSettings> <ig:XamGrid.FilteringSettings> <ig:FilteringSettings AllowFiltering="FilterMenu" FilteringScope="ColumnLayout" /> <!--ig:FilteringSettings AllowFiltering="FilterRowTop" /--> </ig:XamGrid.FilteringSettings>
Hello Gary,
Just checking in, did you have any other questions or concerns on this matter?
Sincerely,AndrewDeveloper Support Engineer IInfragistics Inc.www.infragistics.com/support
To set focus on the XamGrid’s FilterMenu search textbox, I would recommend writing a Style for the primitive FilterSelectionControl and using an EventSetter to handle the Loaded event. This will fire each time the FilterMenu is opened. In the Loaded event handler, cast the sender to a FilterSelectionControl object and use the Utilities class to obtain the FilterTextBox object from the FilterSelectionControl.
Normally, from there, I would recommend just calling FilterTextBox1.Focus(), but it appears there is a timing issue with this, so I would recommend using Dispatcher.BeginInvoke(Action a, DispatcherPriority.Background), where the Action calls FilterTextBox1.Focus().
I have attached a sample application to demonstrate the above.
Please let me know if you have any other questions or concerns on this matter.