Focus On FilterDescriptor

8 posts, 0 answers
  1. davood ramezani
    davood ramezani avatar
    11 posts
    Member since:
    Mar 2010

    Posted 27 Nov 2010 Link to this post

    hello
    how to Set Focus on FilterDescriptor in form load
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 29 Nov 2010 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Mariusz
    Mariusz avatar
    26 posts
    Member since:
    Jul 2011

    Posted 20 Feb 2012 Link to this post

    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
  5. Mariusz
    Mariusz avatar
    26 posts
    Member since:
    Jul 2011

    Posted 20 Feb 2012 Link to this post

    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).
  6. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 20 Feb 2012 Link to this post

    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 >>
  7. Mariusz
    Mariusz avatar
    26 posts
    Member since:
    Jul 2011

    Posted 20 Feb 2012 Link to this post

    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.


  8. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 20 Feb 2012 Link to this post

    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 >>
  9. Mariusz
    Mariusz avatar
    26 posts
    Member since:
    Jul 2011

    Posted 20 Feb 2012 Link to this post

    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.
Back to Top
UI for WPF is Visual Studio 2017 Ready