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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T01:56:46+00:00 2026-05-21T01:56:46+00:00

I have a WPF usercontrol, which contains a toolbar with 5 buttons. The commands

  • 0

I have a WPF usercontrol, which contains a toolbar with 5 buttons. The commands for for of the buttons is handled in the parent Window, but the fifth button’s command is handled by the UC itself. It seems no matter what I try, the button is always disabled. This is my code:

In the user control…

<UserControl.CommandBindings>
<CommandBinding Command="loc:MyAppCommands.OpenUrl" Executed="OpenUrl" />
</UserControl.CommandBindings>

The button in question…

<l49ui:ImageButton Command="loc:MyAppCommands.OpenUrl" CommandParameter="{Binding}" Text="{lex:LocText MyApp.Core:Strings:OpenUrl}"  ShowText="False" ToolTip="{lex:LocText MyApp.Core:Strings:OpenUrl}" Style="{StaticResource ToolBarButton}" 
           Image="{Binding Url,Converter={StaticResource UrlNotNullConverter},ConverterParameter=image}" IsEnabled="true" /> 

The datacoontext for the user control is set based on a list selection; so I have WIndow->UserControl tied to ListBox->TabControl->Toolbar buttons

The image changes based on whether the commandparameter (Url in this case) is empty, and this works. However, the button is always disabled. The only thing which causes it to enable is switching to another tab in a pareent tab control, then back to to tab with the button.

I’ve tried calling CommandManager.InvalidateRequerySuggested(); when the datacontext changes and adding a “CanAlwaysExecute” handler for the command, but the CanExecute handler isn’t executed when I call CommandManager.InvalidateRequerySuggested();.

  • 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-21T01:56:47+00:00Added an answer on May 21, 2026 at 1:56 am

    It might be an issue with focus scopes. Try specifying the CommandTarget property explicitly on your button. Set it to an element inside your user control on which the Execute and CanExecute events should be raised (probably root element inside the user control).

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

Sidebar

Related Questions

I have an interesting problem. I've created a WPF UserControl which contains a button
I have WPF userControl Library project. In it I have window which has next
I have a WPF Window that contains a UserControl with a MinWidth and MinHeight.
In WPF application I have MainWindow : Window which loads a POSView : UserControl
I have a complex WPF UserControl made of other ContentControl templates which contain sets
I have a WPF Window which has a among other controls hosts a Frame.
I have a WPF window for editing database information, which is represented using an
Just trying to get my head round WPF. I have a usercontrol which I'm
I have a really simple WPF UserControl: <UserControl x:Class=dr.SitecoreCompare.WPF.ConnectionEntry xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml x:Name=connEntry BorderBrush=Navy BorderThickness=1
In a WPF UserControl, I have to make to call to a WebService. I

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.