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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:06:14+00:00 2026-05-23T22:06:14+00:00

I have the following custom defined Button defined in my App.xaml file. <Style x:Key=DispatchListCallButton

  • 0

I have the following custom defined Button defined in my App.xaml file.

    <Style x:Key="DispatchListCallButton" TargetType="Button">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border Name="outerBorder" BorderThickness="1" BorderBrush="DimGray" CornerRadius="1" Background="{TemplateBinding Background}">
                        <Border Name="innerBorder" BorderThickness="1" BorderBrush="WhiteSmoke" CornerRadius="1" Background="{TemplateBinding Background}">
                            <Grid Margin="2">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="1*"></RowDefinition>
                                    <RowDefinition Height="2*"></RowDefinition>
                                    <RowDefinition Height="Auto"></RowDefinition>
                                    <RowDefinition Height="1*"></RowDefinition>
                                </Grid.RowDefinitions>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock>2600</TextBlock>
                                    <TextBlock Margin="4,0,0,0">IPRJ</TextBlock>
                                </StackPanel>
                                <TextBlock Grid.Row="1" TextWrapping="Wrap">1234 Main St West Avenue</TextBlock>
                                <Rectangle Grid.Row="2" Height="1" Margin="2,0,2,0" Stroke="DarkGray" />
                                <StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Right">
                                    <TextBlock>1</TextBlock>
                                    <TextBlock Margin="4,0,0,0">*</TextBlock>
                                </StackPanel>
                                <ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Center" Name="content"/>
                            </Grid>
                        </Border>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

I have left off the triggers since I don’t have issues with them.

This displays exactely what I want, accept that all of the values are currently hard coded. There are a total of 5 TextBlock’s as part of this Button. I would like to be able to set up binding for each of these 5 text blocks so that I can set them dynamically in code behind. Ideally this is what I would like my code behind to look like.

        DispatchListCallButton newButton = new DispatchListCallButton();

        // Set the 5 TextBlock values
        newButton.Id = "4444";
        newButton.Code = "ABCD";
        newButton.Address = "2000 Main";
        newButton.Priority = 5;
        newButton.Symbol = "*";

How can I do this and what would the binding expression in the ControlTemplate look like?

  • 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-23T22:06:14+00:00Added an answer on May 23, 2026 at 10:06 pm

    You can do this one of two ways.

    First Method:
    First you would need to create control type that inherited from Button since you cannot modify the button (or instantiate) by the style as you are attempting to now.
    You would then define Id,Code,etc. as DependencyProperties of the control. If they are DependencyProperties then the code will automatically register to listen for changes.

    Article:
    http://msdn.microsoft.com/en-us/library/ms753358.aspx

    Second Method:
    You would define a ViewModel for the button that exposes those properties and implements INotifyPropertyChange. Each time the propertys are set, fire the event. You would then set newButton.DataContext to an instance of the ViewModel and modify the view model. Bindings would be like Text = {Binding Address}

    Article:
    http://msdn.microsoft.com/en-us/library/ms229614.aspx

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

Sidebar

Related Questions

I have an Android (developed on A2.2) app with following theme defined: <style name=ProgressBar>
I have the following XAML code as part of a custom control: <telerik:RadTreeView x:Name=treeModules>
I have created a default style for a Button including a custom ControlTemplate like
In my asp.net web site I have custom error pages defined as following in
I have the following code in WCF service to throw a custom fault based
I have a custom control that has the following prototype. Type.registerNamespace('Demo'); Demo.CustomTextBox = function(element)
I have a custom sharepoint web part that is throwing the following exception: System.Security.SecurityException:
I have following table structure: Table: Plant PlantID: Primary Key PlantName: String Table: Party
I have following text in a file 23456789 When I tried to replace the
I have a custom control derived from Button: class MyControl : Button{} And suppose,

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.