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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:28:37+00:00 2026-05-31T07:28:37+00:00

I am new to wpf and xaml (Windows development in general) and my background

  • 0

I am new to wpf and xaml (Windows development in general) and my background is asp.net and prior to that classic ASP.

I’m working on an application that needs to have the button disabled/grayed out while the processing occurs and read a post on here to do the following but it doesn’t appear to be working. What am I missing?

<Window x:Class="SCGen.Application.LoadForecast.EngineExecution"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:igEditors="http://infragistics.com/Editors"        
    SizeToContent="WidthAndHeight"
    Title="Engine Execution"
    ResizeMode="NoResize"
    WindowStartupLocation="CenterOwner"
    Background="{StaticResource {x:Static SystemColors.ControlBrushKey}}">
<Window.Resources>
    <Style TargetType="{x:Type Button}" x:Key="myStyle" BasedOn="{StaticResource ButtonStyle}">
        <Setter Property="Command" Value="{Binding ExecuteEngine}" />
        <Setter Property="Content" Value="Execute Engine" />
        <Style.Triggers>
            <Trigger Property="Command" Value="{x:Null}">
                <Setter Property="IsEnabled" Value="False"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</Window.Resources>    
<Border Padding="8">
    <StackPanel>
        <StackPanel MaxWidth="200" HorizontalAlignment="Left">
            <TextBlock Text="Select Forecast Engine" TextAlignment="Center" FontSize="13" />

            <igEditors:XamComboEditor ItemsSource="{Binding ForecastEngines}" SelectedItem="{Binding SelectedEngine}" Margin="0,5" />

            <Button Style="{StaticResource ResourceKey=myStyle}" />
        </StackPanel>

        <TextBlock Text="{Binding EngineStatus}" FontSize="15" FontStyle="Italic" Margin="0,14" Width="400" TextWrapping="Wrap" />
    </StackPanel>
</Border>

</Window>

I’ve changed the xaml to the following:

<Button Content="Execute Weather Import" Command="{Binding ExecuteWeather}" Style="{StaticResource ButtonStyle}" IsEnabled="{Binding IsEnabled}"/>

In the ViewModel I have the following:

private bool _isEnabled = true;
    public bool IsEnabled
    { 
        get { return _isEnabled; }
        set { _isEnabled = value; }
    }

and I set the _isEnabled here:

private string LaunchWeatherImport(string strVendor)
    {
        _isEnabled = false;

        string uri = ConfigurationManager.AppSettings["ManualExecutionFacilitatorService"];
        ClientConnectionInfo connection = new ClientConnectionInfo(uri) { UseSecurity = true };
        connection.SetTimeouts();

        Logger.LogInfo("Calling Facilitator service to manually import " + strVendor + " weather data.");

        ((NetTcpBinding)connection.Binding).Security.Mode = System.ServiceModel.SecurityMode.None;

        using (var client = new FacilitatorManualExecutionClient(connection))
        {
            client.InnerChannel.OperationTimeout = TimeSpan.FromMinutes(int.Parse(ConfigurationManager.AppSettings["OperationTimeOutMinutes"]));

            try
            {
                _isEnabled = true;
                return "success";
                // uncomment this line before commit
                //return client.ExecuteWeather(strVendor);
            }
            #region catch
            catch (Exception ex)
            {
                Logger.LogError(ex.Message, ex);
                return ex.Message;
            }
            #endregion
        }
    }

I still can’t get it to work properly.

  • 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-31T07:28:38+00:00Added an answer on May 31, 2026 at 7:28 am

    For starters, you’re setting the trigger on the Command property but you don’t have a binding set on that property for your button:

    <Button Style="{StaticResource ResourceKey=myStyle}" />
    

    Should be:

    <Button Style="{StaticResource ResourceKey=myStyle}" Command="{Binding MyCommand}" />
    

    [Where MyCommand is the name of your actual command that you’re binding to]

    I am not so sure that it will work anyway though because your trigger is set to fire when the Command property is null, but if you bind to the command property, following the MVVM pattern then your command property shouldn’t be null so the trigger won’t fire then either.

    UPDATE:

    You need to implemented the INotifyPropertyChanged interface on your class that has the property.

    public class MyClass : System.ComponentModel.INotifyPropertyChanged
    

    Then add the implementation:

    public event PropertyChangedEventHandler PropertyChanged;
    
    private void NotifyPropertyChanged(String info)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(info));
        }
    }
    

    Then change your property to be:

    private bool _isEnabled = true;
    public bool IsEnabled
    { 
        get { return _isEnabled; }
        set 
        { 
           _isEnabled = value;
           NotifyPropertyChanged("IsEnabled");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created new WPF Application witn two windows. MainWindow.xaml Window1.xaml Added one button in
I'm new to WPF development with C#, and I'm trying to develop an application
I'm kinda new to WPF and .Net programming in general. I have downloaded this
i am porting my application from windows forms to WPF. I have found that
I'm working on a new WPF application and I'm trying to stay as close
I have a keyboard focus problem with Windows Forms application that hosts WPF UserControls.
I'm new to WPF, and created a 1st simplistic WPF application that I want
I'm creating Windows application and Class library. Class library contains WPF control named InsertForm.xaml
I'm porting a DirectX application into WPF, using the Windows.Media.Media3D toolkit. Which is working
In Visual Studio 2008, when you add a new XAML window to a WPF

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.