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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:48:39+00:00 2026-05-23T11:48:39+00:00

I have a user control and in it I have several textbox/ calendar/… controls

  • 0

I have a user control and in it I have several textbox/ calendar/… controls which they all should be enabled or disabled based on a properety in my user control (IsEditing)

I created a dependency property IsEditing in my user control and now I want to define a style that all of the controls use it to became enabled or disabled.

I am trying to do something such as this:

<ad:DocumentContent.Resources>
    <Style x:Key="ReadOnlyMode">
        <Setter Property="HorizontalAlignment" Value="Stretch"/>
        <Setter Property="VerticalAlignment" Value="Stretch"/>
        <Setter Property="Visibility" Value="Visible"/>
        <Setter Property="IsEnabled" Value="False" />
        <Style.Triggers>
            <Trigger Property="IsEditing" Value="True">
                <Setter Property="Background" Value="Green"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</ad:DocumentContent.Resources>

But I am getting this error: Property ‘IsEditing’ was not found in type ‘FrameworkElement’.

How can I address the correct property for triggers?


Update 1:

I defined the IsEditing as follow:

public static readonly DependencyProperty IsEditingProperty = DependencyProperty.Register(
            "IsEditing", typeof(Boolean), typeof(MyDetailDataControl), new PropertyMetadata(false));

And defined styles as follow:

<ad:DocumentContent.Resources>
    <Style x:Key="ReadOnlyMode" xmlns:u="clr-namespace:MyProject.Controls" TargetType="{x:Type u:MyDetailDataControl}">
        <Setter Property="HorizontalAlignment" Value="Stretch"/>
        <Setter Property="VerticalAlignment" Value="Stretch"/>
        <Setter Property="Visibility" Value="Visible"/>
        <Setter Property="IsEnabled" Value="False" />
        <Style.Triggers>
            <Trigger Property="IsEditing" Value="True">
                <Setter Property="Background" Value="Green"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</ad:DocumentContent.Resources>

But I am getting the following error now:
Property ‘IsEditing’ was not found in type ‘MyDetailDataControl’.

I think there is a problem with the dependency property definition.


Update 2:

I changed the xaml as follow (add xmlns:l=”clr-namespace:MyProject.Controls” at the user control section so the namespace became available everywhere) and also used the method which is define here http://www.wpfmentor.com/2009/01/how-to-debug-triggers-using-trigger.html to debug the trigger)

<ad:DocumentContent.Resources>
    <Style x:Key="ReadOnlyMode" TargetType="TextBox">
        <Style.Triggers>
            <Trigger my:TriggerTracing.TriggerName="BoldWhenMouseIsOver" my:TriggerTracing.TraceEnabled="True" Property="l:MyDetailDataControl.IsEditing" Value="True">
                 <Setter Property="TextBox.Background" Value="Green"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</ad:DocumentContent.Resources>

But the trigger is not fired? Do you I need implement notify property mechanism? if yes, how can I do this? Is there any special technique for implementing property change notification when the property is an attached property?


Update 3:
Changed to this version, which is not related to my own IsEditing property. But still doesn’t work.

<ad:DocumentContent.Resources>
    <Style x:Key="MyStyle" TargetType="{x:Type l:MyDetailDataControl}" >
        <Style.Triggers>
            <Trigger my:TriggerTracing.TriggerName="BoldWhenMouseIsOver" my:TriggerTracing.TraceEnabled="True" Property="IsMouseOver" Value="True">
                <Setter Property="FontWeight" Value="Bold"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</ad:DocumentContent.Resources>
  • 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-23T11:48:39+00:00Added an answer on May 23, 2026 at 11:48 am

    You need to set the TargetType of the style to the type of your UserControl. Or you prefix all the properties with it.

    <!-- Using TargetType -->
    <Style xmlns:u="clr-namespace:Test.UserControls"
           x:Key="ReadOnlyMode"
           TargetType="{x:Type u:MyUserControl1}">
        <Style.Triggers>
            <Trigger Property="IsEditing" Value="True">
                <!-- ... -->
            </Trigger>
        </Style.Triggers>
    </Style>
    <!-- Using qualified property -->
    <Style xmlns:u="clr-namespace:Test.UserControls"
           x:Key="ReadOnlyMode">
        <Style.Triggers>
            <Trigger Property="u:MyUserControl1.IsEditing" Value="True">
                <!-- ... -->
            </Trigger>
        </Style.Triggers>
    </Style>
    

    Regarding your other problem: The property needs a CLR-Wrapper:

    public static readonly DependencyProperty IsEditingProperty =
            DependencyProperty.Register("IsEditing", typeof(Boolean), typeof(MyDetailDataControl), new UIPropertyMetadata(false));
    // This:
    public Boolean IsEditing
    {
        get { return (Boolean)GetValue(IsEditingProperty); }
        set { SetValue(IsEditingProperty, value); }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user control that is pretty basic. It contains several TextBox controls,
I have a Windows Forms user control which consists of several controls. Among others
i have user control, which i render on several views. i want to show
I have a web user control that contains several other (web user) controls and
I have several winforms listbox controls I am hosting in a user control. The
I have several similar user controls which display listviews of respectively different data entities.
I have a user control with several child controls. I need the user interface
I have a user control which has several radiobuttons and buttons... I have code
I have a user control that takes a several seconds to load. Is there
I have several user controls, let's say A , B , C and D

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.