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

The Archive Base Latest Questions

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

within my current project file I have a user control that has a storyboard

  • 0

within my current project file I have a user control that has a storyboard animation applied to the control. When a button is clicked in the page the storyboard starts and basically visually presents the control to the user. The storyboard resides in the current page as a resource

<navigation:Page.Resources>
    <Storyboard x:Name="PreferncesOpen">....</Storyboard x:Name="PreferncesOpen">
        </navigation:Page.Resources>

Within the page I have button that I have a click event on that starts the storyboard

private void btnOpenPreferences_Click(object sender, RoutedEventArgs e)
    {
        preferencesPanel.Visibility = System.Windows.Visibility.Visible;
        PreferncesOpen.Begin();
    }

Within the userControl (preferencesPanel) I have a button that when clicked needs to close/collapse the user control. I plan to do this using Visibility.collapsed. I assume that I need to use routed commands since the button is within the user control but the actions need to be called within the page that contains the control? I’m still new to routed commands and I assume this is the correct approach. I’m just unsure how to click on a button within the user control and have it modify or execute commands that would impact how the page (in which this control resides) may change or for that part affect other elements within the page? For example when the button is clicked within the user control I would like the visibility of the user control to be set to collapsed. I also would like to have the width of one of the grid columns within the main page re-size. I have done this in the past using the code behind for the page but I am trying to separate some of this and I thought routed commands would be the way to go?
I’d greatly appreciate any tips.

Thank you in advance

  • 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-21T13:51:56+00:00Added an answer on May 21, 2026 at 1:51 pm

    The title is a bit misleading, you’re asking about commands rather then routed events if I understand you correctly.

    Here’s an example of using a DelegateCommand<T> from the Prism library; It happens to be my personal preference.

    Markup :

    <Button x:Name="MyButton" Content="Btn" Command="{Binding DoSomethingCommand}"/>
    

    Code-behind* or ViewModel :

    (* if you’re not using MVVM make sure to add MyButton.DataContext = this; so you’re sure that the button can databind to your code behind effectively)

    public DelegateCommand<object> DoSomethingCommand
    {
        get 
        { 
            if(mDoSomethingCommand == null)
                mDoSomethingCommand = new DelegateCommand(DoSomething, canDoSomething);
            return mDoSomethingCommand;
        }
    
    private DelegateCommand<object> mDoSomethingCommand;
    
    // here's where the command is actually executed
    void DoSomething(object o)
    {}
    
    // here's where the check is made whether the command can actually be executed
    // insert your own condition here
    bool canDoSomething(object o)
    { return true; }
    
    
    // here's how you can force the command to check whether it can be executed
    // typically a reaction for a PropertyChanged event or whatever you like
    DoSomethingCommand.RaiseCanExecuteChanged();
    

    The argument that’s passed to the above function is the CommandParameter dependency property (in Prism it’s an attached property as well as the Command property if memory serves me right).
    When it’s set, you can pass a value of your choosing to the command that you wish to execute.

    Hope that helps.

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

Sidebar

Related Questions

My current application has a JFrame with about 15 actions stored as fields within
Within Ruby on Rails applications database.yml is a plain text file that stores database
Is is possible to query the current browser from within an applet? I would
Is there a way to get the current folder path from within a XSLT
I need to know, from within Powershell, if the current drive is a mapped
Within our Active Directory domain, we have a MS SQL 2005 server, and a
I am having difficulty in printing to a text file from chosen locations within
I have a Python 3 project where I'm dynamically importing modules from disk, using
I've got maven project that I want to be able to move some properties
Within an application, I've got Secret Keys uses to calculate a hash for an

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.