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 214983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:25:36+00:00 2026-05-11T18:25:36+00:00

I am using the Infragistics XamDateTimeEditor control and I want to add a dependency

  • 0

I am using the Infragistics XamDateTimeEditor control and I want to add a dependency property to it to allow the developer to choose to have all the text selected when the control gets focus. I have created a style that is used to set the behavior I want but I want the developer to decide if the behavior should be executed based on a boolean dependency property. I am not sure how that is done.

  • 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-11T18:25:36+00:00Added an answer on May 11, 2026 at 6:25 pm

    I assume you inherited from XamDateTimeEditor for this.

    If you can write the code referencing a “standard” (clr) property, then you are good to go:

    1. declare your DependencyProperty
    2. remove your backing field and replace the implementation of the standard property so that it accesses the DependencyProperty instead of the backing field.

      public class MyXamDateTimeEditor : XamDateTimeEditor
      {
          public static readonly DependencyProperty IsSelectOnFocusEnabledProperty = 
            DependencyProperty.Register("IsSelectOnFocusEnabled", typeof(bool), 
          typeof(MyXamDateTimeEditor), new UIPropertyMetadata(false));
      
          public boolIsSelectOnFocusEnabled
          {
              get
              {
                  return (bool)GetValue(IsSelectOnFocusEnabledProperty);
              }
              set
              {
                  SetValue(IsSelectOnFocusEnabledProperty, value);
              }
          }
      }
      

    Then, when you access IsSelectOnFocusEnabled in your code it will return the current value of the Dependency Property.

    You can also set it up to receive notification whenever the property changes, but I don’t see why you would in your case.

    There is also another option for this trick, which uses no inheritance and an attached property if you’d like.

    UPDATE:

    OK, since it was requested, here’s a way to achieve that for any textbox. It should be easy to translate to whatever event you use to carry that out on another type of control.

        public class TextBoxBehaviors
        {
            public static bool GetIsSelectOnFocusEnabled(DependencyObject obj)
            {
                return (bool)obj.GetValue(IsSelectOnFocusEnabledProperty);
            }
    
            public static void SetIsSelectOnFocusEnabled(DependencyObject obj, bool value)
            {
                obj.SetValue(IsSelectOnFocusEnabledProperty, value);
            }
    
            public static readonly DependencyProperty IsSelectOnFocusEnabledProperty =
                DependencyProperty.RegisterAttached("IsSelectOnFocusEnabled", typeof(bool), 
                typeof(TextBoxBehaviors), 
                new UIPropertyMetadata(false, new PropertyChangedCallback(OnSelectOnFocusChange)));
    
            private static void OnSelectOnFocusChange(DependencyObject d, DependencyPropertyChangedEventArgs e)
            {
                if (d is TextBox)
                {
                    var tb = d as TextBox;
                    if ((bool)e.NewValue)
                    {
                        tb.GotFocus += new RoutedEventHandler(tb_GotFocus);
                    }
                    else
                    {
                        tb.GotFocus -= new RoutedEventHandler(tb_GotFocus);
                    }
                }
            }
    
            static void tb_GotFocus(object sender, RoutedEventArgs e)
            {
                var tb = sender as TextBox;
    
                tb.SelectAll();
            }
    
        }
    

    The way you use it is as follows, for example:

    <Window x:Class="WpfApplication2.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:WpfApplication2"        
        Title="Window1" Height="300" Width="300">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <TextBox Text="No Select All" x:Name="TextBox1"/>
            <CheckBox Content="Auto Select"
                      Grid.Column="1"
                      IsChecked="{Binding Path=(local:TextBoxBehaviors.IsSelectOnFocusEnabled), ElementName=TextBox1, Mode=TwoWay}" />
            <TextBox Grid.Row="1" Text="djkhfskhfkdssdkj"
                     local:TextBoxBehaviors.IsSelectOnFocusEnabled="true" />
        </Grid>
    </Window>
    

    This shows you how to set up the property to activate the behavior, and how to bind it to something else if need be.
    Note that this specific example is not perfect (if you tab through it works, if you click inside the control, the textbox has internal logic that actually deselects the text, but that’s just an example on how to attach behaviors to controls through attached properties).

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

Sidebar

Related Questions

I have a problem using Infragistics UltraTree control. I need a way to add
I am using an Infragistics UltraWinGrid v9.1. I want to allow the user to
I'm using the Infragistics UltraWebGrid control and have the following layout: <igtbl:UltraWebGrid ID=uwgPrescribedTrainingPlan runat=server
We're using Infragistics grid (most probably, we'll have 8.2 version at the end) and
I am using the Infragistics UltraWebGrid to capture some data. I don't have this
I have been using the Infragistics UltraWebGrids for a few years now in multiple
I am currently using the UltraWebGrid control of Infragistics and I am displaying the
I'm developing a web site, and i'm using infragistics for web, but I want
I added dynamicly infragistics webpanel in my codebehind using : placeHolder.Controls.Add(ctlWebpanel); but i got
I have UserControl that holds Infragistics Graph control. On the TreeView sub node's right

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.