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

The Archive Base Latest Questions

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

I have just started working with with Styles and Control Templates and have created

  • 0

I have just started working with with Styles and Control Templates and have created the following styles to display a button as text in a grid. I would like to embed Font Styling into the styles for underlining but have not figured it out.

<Style x:Key="TextButtonStyle" TargetType="Button">
    <Setter Property="Background" Value="LightGray" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="ContentControl">
                <ContentPresenter Content="{TemplateBinding Content}" />
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

<Style x:Key="TextButtonInGridStyle" TargetType="Button" BasedOn="{StaticResource TextButtonStyle}">
    <Setter Property="VerticalAlignment" Value="Center" />
    <Setter Property="Margin" Value="4,4,4,4" />
</Style>

I would like to embed Font Styling into the styles for underlining but have not figured it out. Is there any way to do this without embedding a TextBlock into the ControlTemplate or nesting a TextBlock in the Button element declaration?

Thanks

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

    You definitely can, or maybe I don’t understand the problem, but see if this example is what you’re after:

    <UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
    x:Class="SilverlightApplication1.MainPage"
    Width="640" Height="480">
    <UserControl.Resources>
        <Style x:Key="TextButtonStyle" TargetType="Button">
            <Setter Property="Background" Value="LightGray" />
            <Setter Property="Template">
                <Setter.Value>
                        <ControlTemplate TargetType="ContentControl">
                                <ContentPresenter Content="{TemplateBinding Content}" />
                        </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="TextButtonInGridStyle" TargetType="Button" BasedOn="{StaticResource TextButtonStyle}">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Margin" Value="4,4,4,4" />
            <Setter Property="FontFamily" Value="Arial"/>
            <Setter Property="FontWeight" Value="Bold"/>
            <Setter Property="Foreground" Value="Red"/>
        </Style>
    </UserControl.Resources>
    
    <StackPanel x:Name="LayoutRoot" Background="White">
        <Button Content="Button" Style="{StaticResource TextButtonStyle}"/>
        <Button HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="75" Style="{StaticResource TextButtonInGridStyle}" Margin="4,0,0,0">
            Button
        </Button>
        <Button HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="75" Style="{StaticResource TextButtonInGridStyle}" Margin="4,0,0,0">
            <Rectangle Fill="#FFF4F4F5" Height="10" Stroke="Black"/>
        </Button>
    </StackPanel>
    

    You can see that there’s no TextBlock in the Button, and if the content is a rectangle it’ll be shown instead of the text nicely.

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

Sidebar

Related Questions

I have just started working with Symfony. I downloaded the sf_sandbox and I am
I have just started working on a struts2 project. I have seen the power
I have just started working with C++ code compiled in Visual Studio 2008. The
So I have just started working with HTML5 and the Canvas element. I'm working
Since I have just started working with Facebook's api I had a few questions
I have just started playing around with using Dojo in Zend Framework and things
Context I have written a TreeList/TreeGrid (i.e. tree with columns) control that inherits the
I'm just getting started with jQuery, having a little trouble. Got a table of
I'm getting the following error when trying to add files to my mercurial repo.
Summary I'm a seasoned programmer with years of experience in Windows Forms development using

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.