Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6884243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:28:59+00:00 2026-05-27T05:28:59+00:00

I got a CustomControl inherit from : Control. It contains 2 Labels, 1 TextBox

  • 0

I got a CustomControl inherit from : Control. It contains 2 Labels, 1 TextBox and 2 Buttons (simplyfied view)

<Button IsTabStop="False" x:Name="ParameterUpButton" IsEnabled="False" Width="14" Height="10">
<Button IsTabStop="False" x:Name="ParameterDownButton" IsEnabled="False" Width="14" Height="10"/>

<StackPanel Orientation="Horizontal" Height="28" VerticalAlignment="Center">
   <Label Content="{TemplateBinding ParameterName}" Width="45" />
   <TextBox IsEnabled="False" x:Name="ParameterValueTextBox" Text="{TemplateBinding ParameterValue}" Width="36" Height="23"/>
   <Label Content="{TemplateBinding ParameterUnit}" Width="33" />
</StackPanel>

As the user should be able to navigate through some of these custom controls, i want to redirect the Focus by tabbing through my controls. Simply said:

I want to navigate through all these Textboxes, and only those (the buttons should be no tab stops!).

The Buttons and the Textbox are disabled by default, and the template got some triggers to enable them by IsMouseOver and by IsKeyboardFocused (to show a different style).

How can i focus the Textbox (and enable it including the two buttons)

  • using Tab to navigate through my controls?
  • by clicking on my control (no matter where, just within the control)

The usage looks like the following:

<!-- some more controls -->
<CustomControls:ParameterControl ParameterName="foo" ParameterUnit="x" ParameterValue="6" Margin="5"/>
<CustomControls:ParameterControl ParameterName="bar" ParameterUnit="y" ParameterValue="6" Margin="5"/>
<CustomControls:ParameterControl ParameterName="foobar" ParameterUnit="z" ParameterValue="6" Margin="5"/>
<!-- some more controls -->

Thanks for any help in advance!

Edit: I tried it by overriding the Control’s OnGotFocus event like this:

protected override void OnGotFocus(RoutedEventArgs e)
{
      var tb = ((TextBox) Template.FindName("ParameterValueTextBox", this));
      tb.IsEnabled = true;
      tb.Focus();
}

I also wrote a Trigger for my Control:

<MultiTrigger>
   <MultiTrigger.Conditions>
      <Condition SourceName="ParameterValueTextBox" Property="IsKeyboardFocused" Value="true"/>
   </MultiTrigger.Conditions>
   <MultiTrigger.Setters>
      <Setter Property="IsEnabled" TargetName="ParameterDownButton" Value="true"/>
      <Setter Property="IsEnabled" TargetName="ParameterUpButton" Value="true"/>
      <Setter Property="IsEnabled" TargetName="ParameterValueTextBox" Value="true"/>
   </MultiTrigger.Setters>
</MultiTrigger>

Actually, this trigger works for the Buttons (i can see the style changing and changing back after losing the focus), but my TextBox is still being enabled (at least the style does not change back)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:29:00+00:00Added an answer on May 27, 2026 at 5:29 am

    Meanwhile, i’ve found the solution myself. Might be interesting to somebody else:

    As i’ve been juggling around with IsEnabled and setting the focus to the input field, i think there might be some problem in the order the triggers, styles and function calls in the Class of my Control. Anyway, i’ve solved it in the following way:

    I removed these three setters

    <MultiTrigger.Setters>
      <Setter Property="IsEnabled" TargetName="ParameterDownButton" Value="true"/>
      <Setter Property="IsEnabled" TargetName="ParameterUpButton" Value="true"/>
      <Setter Property="IsEnabled" TargetName="ParameterValueTextBox" Value="true"/>
    </MultiTrigger.Setters>
    

    to

    <MultiTrigger.Setters>
      <Setter Property="Tag" TargetName="ParameterDownButton" Value="Enabled"/>
      <Setter Property="Tag" TargetName="ParameterUpButton" Value="Enabled"/>
      <Setter Property="Tag" TargetName="ParameterValueTextBox" Value="Enabled"/>
    </MultiTrigger.Setters>
    

    And enabled the buttons all the time. After having applied the style triggers to the Tag Property, everything looks the same and works perfectly. There might be a problem else to focus a disabled element (depends on the order the setters, styles and code within the Class itself are invoked).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a custom control ive created that is instanced in my view, in
I've got a custom control that inherits from Panel . At Load-time, I want
I've got a custom control that descends from TTreeView. I'm trying to give it
I've got a custom control that I'm using on a View in my MVVM
I've got Custom Control with a TextBox in the default Template. The Custom Control
I've got a custom control class in my project called CarSystemWindow. It descends from
Got a crash report from a beta tester and I'm having trouble identifying the
Hey SO, so I've got a custom control in Silverlight. Doesn't really matter what
I've got a simple custom control : namespace Application.Custom_Controls { public class ReadOnlyTextBox :
I've got a Silverlight 4 custom control that basically is several Canvas elements wrapped

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.