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

  • SEARCH
  • Home
  • 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 6130929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:54:55+00:00 2026-05-23T16:54:55+00:00

I am having an issue when using a DataTrigger to manipulate the IsEnabled property

  • 0

I am having an issue when using a DataTrigger to manipulate the IsEnabled property of a control. Normally it works fine, however when I initialize the IsEnabled state within the View’s Initialized event, the dynamic stylizing no longer works.

Here’s my code. I trimmed it down to the simplest example I could.

Why is this occurring, and what can I do to allow me to set IsEnabled both by a style trigger and by initializing it in the code behind?

Thanks in advance!

View:

(Contains a textbox that should be enabled/disabled depending on the value of a checkbox)

<Window x:Class="IsEnabled.Views.MainView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Initialized="Window_Initialized">
    <StackPanel Orientation="Vertical">
        <TextBox x:Name="txtTarget" Width="200">
            <TextBox.Style>
                <Style TargetType="{x:Type TextBox}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Path=ToggleValue}" Value="True">
                            <Setter Property="IsEnabled" Value="False" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </TextBox.Style>
        </TextBox>
        <CheckBox x:Name="chkSource" IsChecked="{Binding Path=ToggleValue}" />
    </StackPanel>
</Window>

View Codebehind:

(The only addition is the implementation of the Initialized event setting the inital state for IsEnabled)

using System;
using System.Windows;

namespace IsEnabled.Views
{
    public partial class MainView : Window
    {
        public MainView()
        {
            InitializeComponent();
        }

        private void Window_Initialized(object sender, EventArgs e)
        {
            txtTarget.IsEnabled = false;
        }
    }
}

ViewModel:

(ViewModelBase holds the implementation of the INotifyPropertyChanged interface)

using System;

namespace IsEnabled.ViewModels
{
    class MainViewModel : ViewModelBase
    {
        private bool _ToggleValue;
        public bool ToggleValue
        {
            get { return _ToggleValue; }
            set
            {
                _ToggleValue = value;
                OnPropertyChanged(this, "ToggleValue");
            }
        }
    }
}
  • 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-23T16:54:55+00:00Added an answer on May 23, 2026 at 4:54 pm

    Have a look at dependency property value precedence, and how changing values from different places, Styles, Triggers, Animations etc. work together.

    Add to your Binding Mode=TwoWay and it should work.

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

Sidebar

Related Questions

I am having an issue using the maxrows property of tilelist. My code looks
I'm having an issue using Stripes validation method. It works but rather than returning
I am having an issue using the Moq library to mock an Enum within
I am having a issue using Google's SDC (Secure Data Connector) with my Google
I'm having an issue using the Cookie class of the Servlet API 2.5 on
I believe I am having a memory issue using numpy arrays. The following code
i'm having a little issue with doctrine using symfony 1.4 (I think it's using
I'm having an issue verifying if a checkbox is checked using jquery on Internet
I'm having an issue in IE 6 and 7 when using jqGrid (v3.6.4) and
I am having an issue removing %3Cbr+%2F%3E from my string using the preg_replace function.

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.