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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:11:55+00:00 2026-06-15T08:11:55+00:00

how to talk toolbar (it is a user control) on the button to enable

  • 0

how to talk toolbar (it is a user control) on the button to enable a wait cursor.
i have a ViewModel is inherited from viewmodelBase. But i can not use IsWorking on toolbar.

Below code is toolbar’s code. i clicked select button. data is selecting from database. Cursor must be turn to wait.after Selecting, Cursor must return normal.



    <Button x:Name="Select"
            Content="select"
            Command="{Binding SelectCommand }">
        <Button.Style>
             <Style TargetType="{x:Type Button}">
                 <Setter Property="Cursor" Value="Arrow"/>
                 <Style.Triggers>
                     <DataTrigger Binding="{Binding Path=IsWorking}" Value="True">
                         <Setter Property="Cursor" Value="Wait"/>
                     </DataTrigger>
                 </Style.Triggers>
             </Style>
        </Button.Style>
    </Button>

ViewModelBase.cs: there is no inheritance with toolbar. it is a basemodel.

private bool _isWorking = false;
public bool IsWorking
{
    get { return _isWorking; }
    set
    {
        _isWorking = value;
        OnPropertyChanged("IsWorking");
    }
}

Here is the code from the view-model:

public class MainViewModel : ViewModelBase
{
    public void Select()
    {
        IsWorking = true;     cursor turn to wait mode
        // db Process...

        IsWorking = false;  cursor turn to hand mode
    }
}

How to communicate with toolbar from ViewModel? Click select Cursor must be turn Wait mode. after selection, cursor must be hand(default).

Changing the cursor in WPF sometimes works, sometimes doesn't

enter image description here

  • 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-06-15T08:11:56+00:00Added an answer on June 15, 2026 at 8:11 am

    From what I see, your problem is that you’re trying to bind from your UserControl back to the view/window in which it’s located.

    The usercontrol, of course, will not be able to bind like this.
    You have a few options:

    1 . Give the UserControl the View’s datacontext:

    <local:UserControl1 DataContext="{Binding ElementName=MyWindow}" />
    

    and then in your UserControl you can bind to the ViewModel’s IsWorking directly:

    <DataTrigger Binding="{Binding IsWorking}" Value="True">
      <Setter Property="Cursor" Value="Wait"/>
    </DataTrigger>
    

    2 .
    Create a Dependency Property on your UserControl and bind to it from the view:
    In your usercontrol create a new DP:

    public bool MyIsWorking
    {
      get { return (bool)GetValue(MyIsWorkingProperty ); }
      set { SetValue(MyIsWorkingProperty , value); }
    }
    
    public static readonly DependencyProperty MyIsWorkingProperty =
            DependencyProperty.Register("MyIsWorking", typeof(bool), typeof(UserControl1),    new UIPropertyMetadata(false));
    

    In the usercontrol’s XAML bind to the DP:

    <DataTrigger Binding="{Binding MyIsWorking}" Value="True">
            <Setter Property="Cursor" Value="Wait"/>
    </DataTrigger>
    

    In your window – bind the DP to the VM’s IsWorking property:

    <local:UserControl1 MyIsWorking="{Binding IsWorking, ElementName=MyWindow}" />
    

    3 . Finally this will work but it’s not recommended!!!**

    <DataTrigger Binding="{Binding IsWorking, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}" Value="True">
        <Setter Property="Cursor" Value="Wait"/>
    </DataTrigger>
    

    What this does is tries to find the Window in the Visual Tree and use its DataContext. Why isn’t it recommended? Because you might not be using this in a Window or you might not want it to be bound to the specific DataContext the containing Window is using. Either way, it IS another possibility.

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

Sidebar

Related Questions

They talk about the different utilization instances, but I can't find a single place
The docs talk about how to use various middleware (app.use) but I can't find
Im trying to have a page talk to an extension using chrome.extension.connect, but the
When we talk about security we have the following requirements: authentication integrity Non-repudiation Isn't
All the talk on WP7 resolution = 800x480. I can create more than 480
How does Google Talk get the current song played? Can I do this using
I'm creating Google talk client for iOS. I have BOSH server (used node-xmpp-bosh) and
Lots of people talk about the performance advantages of String.intern(), but I'm actually more
I have this ant talk to copy cgi-dir to cgi-dest. <exec executable=cp failonerror=yes> <arg
I'm trying to talk to a USB device using libusb, but I feel like

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.