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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:09:38+00:00 2026-05-18T22:09:38+00:00

I have a bunch of controls using identical interactions triggers across multiple user controls

  • 0

I have a bunch of controls using identical interactions triggers across multiple user controls and viewmodels. Is it possible to place these triggers somehow into a resource dictionary for reuse? Here’s an example of what a control might look like.

       <TextBox x:Name="FirstName" Grid.Row="1" Grid.Column="1">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="KeyDown">
                    <cal:ActionMessage MethodName="KeyPressed" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </TextBox>

       <TextBox x:Name="Initial" Grid.Row="1" Grid.Column="1">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="KeyDown">
                    <cal:ActionMessage MethodName="KeyPressed" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </TextBox>

       <TextBox x:Name="LastName" Grid.Row="1" Grid.Column="1">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="KeyDown">
                    <cal:ActionMessage MethodName="KeyPressed" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </TextBox>

The cal: namespace is from the Caliburn.Micro MVVM framework and probably isn’t relevant to this question.

  • 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-18T22:09:38+00:00Added an answer on May 18, 2026 at 10:09 pm

    Its not possible to re-use a single instance of Interaction.Triggers in a resource because it becomes attached a control. That attachment becomes part of its state hence a single instance can’t be shared by multiple controls.

    You would need to include the Interaction.Triggers in a template so that multiple instances are created. I guess something like the following might work, (warning air code).

    <UserControl.Resources>
       <DataTemplate x:key="MyTextBox">
          <TextBox>
              <i:Interaction.Triggers>
                  <i:EventTrigger EventName="KeyDown">
                      <cal:ActionMessage MethodName="KeyPressed" />
                  </i:EventTrigger>
              </i:Interaction.Triggers>
          </TextBox>
       </DataTemplate>
    </UserControl.Resources>
    

    …

    <ContentPresenter x:Name="FirstName" Grid.Row="1" Grid.Column="1" ContentTemplate="{StaticResource MyTextBox}" />
    <ContentPresenter x:Name="Initial" Grid.Row="1" Grid.Column="1" ContentTemplate="{StaticResource MyTextBox}" />
    <ContentPresenter x:Name="LastName" Grid.Row="1" Grid.Column="1" ContentTemplate="{StaticResource MyTextBox}" />
    

    It my opinion that this sort of stuff isn’t worth it. The Interaction Triggers stuff is really aimed at empowering the designer rather than the developer. A designer isn’t that worried that there is some repeatition in the “code”.

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

Sidebar

Related Questions

I have a Winforms project with a bunch of User controls. I'd like the
We have a bunch of user controls we would like to pull out of
I have a bunch of controls (textbox and combobox) on a form with toolstripcontainer
I have a bunch of controls on my window. One of them is a
I have a bunch of controls derived from System.Windows.Forms.UserControl, which are then being displayed
I have bunch of HTML code I am using to make rounded edge boxes
I have a bunch of custom controls based on a SkinnableContainer. When adding the
Does Java and/or Spring have the concept of properties? I have bunch of domain
I have a bunch of files that I need to be able to transport
I have a bunch of latitude/longitude pairs that map to known x/y coordinates on

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.