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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:17:23+00:00 2026-05-28T16:17:23+00:00

i built a control template, with two buttons, which i use in the MainWindow

  • 0

i built a control template, with two buttons, which i use in the MainWindow Class:

The ControlTemplate:

<ControlTemplate x:Key="LeftPanelTemplate">
    <Grid  Grid.Column="0"  Grid.Row="0" Margin="10,15,5,5" >
        <Border BorderThickness="7" CornerRadius="4">
            <Border.BorderBrush>
                <SolidColorBrush Color="#73B2F5" Opacity="0.5"/>
            </Border.BorderBrush>
            <Grid>
                <Grid.Background>
                    <SolidColorBrush Color="#73B2F5" Opacity="0.5"/>
                </Grid.Background>
                <Grid.RowDefinitions>
                    <RowDefinition Height="30"/>
                    <RowDefinition Height="1*"/>
                </Grid.RowDefinitions>
                <Button Name="CustomerButton" Grid.Row="1" Grid.Column="0" Width="40" Height="40" Content="Customer" Click="CustTabButton_Click" ></Button>
                <Button Name="BossButton" Grid.Row="1" Width="40" Height="40" Content="Boss" Margin="23,206,23,114" Click="BossTabButton_Click"></Button>
            </Grid>
        </Border>
    </Grid>
</ControlTemplate>

I reference it at the MainWindow XAML:

<ContentControl Template="{StaticResource LeftPanelTemplate}"/>

i get an error that the click events of the two buttons inside the control template could not be found – because i moved it to the ResourceDirectory file called MainWindowResources.xaml:

‘MyWPFApp.MainWindowResource’ does not contain a definition for
‘CustTabButton_Click’ and no extension method ‘CustTabButton_Click’
accepting a first argument of type ‘MyWPFApp.MainWindowResource’ could
be found (are you missing a using directive or an assembly reference?)

i found this link: Is it possible to set code behind a resource dictionary in WPF for event handling?

is there a shorter way for the click events in the MainWindow code behind to be executed from the resource Directory? because moving the whole code from the MainWindow to a REsourceDirectory.xaml.code can take alot of time and expose to public alot of variables.

  • 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-28T16:17:24+00:00Added an answer on May 28, 2026 at 4:17 pm

    you could use commands instead of button click and bind the commands from your mainwindow to the usercontrol.

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

Sidebar

Related Questions

I use a custom-built asp.net control that renders to a DIV and has height='0'
I've built a ascx control and I would like to be able to keep
I've built a custom control, and I'd like to allow people to click and
iv used the built in membership control for my ASP.net project, this create the
I have an ASP control custom built and I need to pass a value
I've written a control in C# that overrides the built-in DropDownList control. For this
Ok guys and gals, here is my problem: I've built a custom control that
I've built a C# .NET app that uses the Adobe ActiveX control to display
I'm attempting to create a custom calendar control that inherits from ASP.Net's built in
I have installed the new asp:chart control on my machine and have built 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.