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

Focus On FilterDescriptor

7 Answers 127 Views
DataFilter
This is a migrated thread and some comments may be shown as answers.
davood ramezani
Top achievements
Rank 1
davood ramezani asked on 27 Nov 2010, 11:01 AM
hello
how to Set Focus on FilterDescriptor in form load

7 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 29 Nov 2010, 11:44 AM
Hi davood ramezani,

The FilterDescriptor is not an UI element. How do you want to focus it? Please, elaborate.

Kind regards,
Ross
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Mariusz
Top achievements
Rank 1
answered on 20 Feb 2012, 11:02 AM
The same problem here.
I have filter with default filter descriptors. When form loads I want to focus first input control.
I have tried something like this for TextBox - input (rdFilter is RadDataFilter type):
void FilterDescriptorsWn_Loaded(object sender, RoutedEventArgs e)
    {
        TextBox tbToFocus = Extensions.VisualHelpers.FindElementOfType(rdFilter, typeof(TextBox)) as TextBox;
       
        if (tbToFocus != null) Dispatcher.BeginInvoke((EventHandler)delegate {
            tbToFocus.Focus();
        },  new object[2]);
 
         
    }
But it doesn't work.
Please help
0
Mariusz
Top achievements
Rank 1
answered on 20 Feb 2012, 11:48 AM
And next problem. When the user press TabKey next input control (in next FilterDescriptor) should be focused. Now, it is focused next nearest control (eg. button).
0
Rossen Hristov
Telerik team
answered on 20 Feb 2012, 12:33 PM
Hello,

The focus logic is handled by the .NET Framework. When you press Tab the next UIElement in the Tab order is focused and that is the normal "by design" behavior of the Framework.

You can't expect the focus logic to skip several controls and go to the next editor directly. What about the people who want to change the Member Name from the combo, then Tab, then change the FilterOperator from the next combo, then Tab, then edit value in the editor, then Tab, then check/uncheck the MatchCase button, then Tab and go down to next line. What about them?

This is the default tabbing order and that this could not be changed.

I hope this makes sense.

All the best,
Ross
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Mariusz
Top achievements
Rank 1
answered on 20 Feb 2012, 01:13 PM
Here is simple code how to achive focus on Texboxes only, event if we have a lot of others control:

<StackPanel Name="stFilterDesciptorUI" Orientation="Vertical" Grid.Column="0" Grid.Row="0" KeyboardNavigation.TabNavigation="Cycle">
          <StackPanel  Name="stFilterDesciptorUI1" Orientation="Horizontal" Focusable="False">
              <Button Focusable="False">Add</Button>
              <ComboBox Focusable="False"></ComboBox>
              <TextBox Width="100" Name="tbFilterDesciptorUI1"></TextBox>
              <Button Focusable="False">Remove</Button>
          </StackPanel>
 
          <StackPanel Name="stFilterDesciptorUI2" Orientation="Horizontal" Focusable="False">
              <Button  Focusable="False">Add</Button>
              <ComboBox Focusable="False"></ComboBox>
              <TextBox Width="100" Name="tbFilterDesciptorUI2"></TextBox>
              <Button Focusable="False">Remove</Button>
          </StackPanel>
 
          <StackPanel Name="stFilterDesciptorUI3" Orientation="Horizontal" Focusable="False">
              <Button Focusable="False">Add</Button>
              <ComboBox Focusable="False"></ComboBox>
              <TextBox Width="100" Name="tbFilterDesciptorUI3"></TextBox>
              <Button Focusable="False">Remove</Button>
          </StackPanel>
      </StackPanel>

What with other users? Simply add property called FocusMode and properies Focusable="False" will depends on selected FocusMode.

Perhaps for only my purpose it will be easier to somehow use Style and set default values for controls with are rendered by DateFilter?

What with my prevoius question. How to focus first input element: I workaround that using code:
protected override void OnOpened(EventArgs args)
     {
         base.OnOpened(args);
 
         DispatcherTimer timer = new DispatcherTimer();
         timer.Tick += (o, e) =>
         {
             TextBox tbToFocus = Extensions.VisualHelpers.FindElementOfType(rdFilter, typeof(TextBox)) as TextBox;
             if (tbToFocus != null) tbToFocus.Focus();
             timer.Stop();
         };
         timer.Interval = TimeSpan.FromSeconds(0.1);
         timer.Start();
     }
It works, but It's not nice solution.


0
Rossen Hristov
Telerik team
answered on 20 Feb 2012, 01:54 PM
Hi,

Maybe there was some kind of misunderstanding here. Are we talking about RadDataFilter for WPF here?

I am not sure where this XAML comes from. We do not have anything similar in RadDataFilter for WPF. The control template for RadDataFilter is entirely different from this XAML so I am not sure what this actually is. Did you invent this XAML?

If you want to make some of the child controls not focusable, then you can edit the control template of the FilterControl component (this is the thing that contains the two combo-boxes and the editor) and mark them with IsTabStop=false. We can not make a new property called FocusMode since this does not make a lot of sense. If it did, then all other WPF controls in the world would have such property and that would be built-in the .NET Framework to begin with. So I am afraid that we cannot add this new property.

As for your other question, I am afraid that there isn't a more elegant way to focus the first editor form the one that you have already discovered.

Kind regards,

Ross
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Mariusz
Top achievements
Rank 1
answered on 20 Feb 2012, 02:08 PM
Thanks for replay.
 I have done something like this:
<telerik:RadDataFilter Grid.Row="1" Name="rdFilter"  >
        <telerik:RadDataFilter.Style>
            <Style>
                <Style.Resources>
                    <Style TargetType="{x:Type telerik:RadButton}">
                        <Setter Property="Focusable"  Value="False"></Setter>
                    </Style>
                    <Style TargetType="{x:Type telerik:RadComboBox}">
                        <Setter Property="Focusable"  Value="False"></Setter>
                    </Style>
                    <Style TargetType="{x:Type telerik:RadToggleButton}">
                        <Setter Property="Focusable"  Value="False"></Setter>
                    </Style>
                    <Style TargetType="{x:Type df:FilterEditor}">
                        <Setter Property="Focusable"  Value="False"></Setter>
                    </Style>
                </Style.Resources>
            </Style>
        </telerik:RadDataFilter.Style>
         
         
  </telerik:RadDataFilter>
It almost works good, but the focus still stops on AddFilter and RemoveFilter buttons. Other controls: ComboBoxes, ToggleButtons are not focusable :). I think that problem may be with other element of visual tree that is parent of AddFilter button.
Please help.
Tags
DataFilter
Asked by
davood ramezani
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Mariusz
Top achievements
Rank 1
Share this question
or