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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:16:50+00:00 2026-05-27T08:16:50+00:00

I have a button defined in my XAML which has a button style and

  • 0

I have a button defined in my XAML which has a button style and a vector graphic, it is defined thus:

    <Button
        Height="48"
        Width="48"
        mvp:Presenter.Action="CreateStudentApplication"
        HorizontalAlignment="Center"
        VerticalAlignment="Center"
        Grid.Row="5"
        Grid.Column="3"
        Style="{DynamicResource BaseButton2}">
        <ContentControl Template="{StaticResource ApplicationVector}"/>
    </Button>

In my code-behind, I have a method that dynamically adds new buttons similar to this one to a StackPanel. In brief, it does something to the tune of:

            var button = new Button();
            button.Height = 48;
            button.Width = 48;
            button.Tag = x.ID;
            button.SetResourceReference(TemplateProperty, "ApplicationVector");
            button.SetResourceReference(StyleProperty, "BaseButton2");

Now here’s the weird part- It displays only the vector graphic, and no button behind it. When I remove the penultimate line (the line with the vector reference), it displays the button styled as it should be! I’m assuming that setting the template is overriding the style, however they seem to play amicably in XAML. I have also tried setting the ContentProperty instidead of TemplateProperty, but this resulted in a string of the type. Any ideas? Thank you!

  • 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-27T08:16:50+00:00Added an answer on May 27, 2026 at 8:16 am

    Your XAML and code behind are not equivalent. In the XAML, you are setting the Content property of the button to be a ContentControl. In the code behind, you are setting the Template (or Content) property to be the ApplicationVector resource.

    You would need to set the Content property of the button to be an instance of a ContentControl whose Template property is set to be your ApplicationVector resource.

    var contentControl = new ContentControl();
    contentControl.SetResourceReference(TemplateProperty, "ApplicationVector");
    button.Content = contentControl;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following custom defined Button defined in my App.xaml file. <Style x:Key=DispatchListCallButton
I have defined a visual state in which a button has a glow effect.
I have defined in XAML a list view, see following fragment: <Grid> <Button Content=_Generate
I have button, which fires an event, that deletes a record from the database.
I have the next problem. I have a ItemsControl defined with xaml. <Grid> <Grid.RowDefinitions>
I have defined one Thickness resource in Window's resources collection which is set to
We've an application in which we have the default control styles defined as implicit
I have a button control which its template is stilyzed in an external resource
I have one issue with Datetime Picker In my firstview i have button.If i
I have one issue with UInavigationcontroller In my firstview i have button.If i click

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.