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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:47:38+00:00 2026-06-03T23:47:38+00:00

I create a custom button in my application as following <Button x:Class=MyApp.ButtonMainMenuSubCat xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml

  • 0

I create a custom button in my application as following

<Button x:Class="MyApp.ButtonMainMenuSubCat"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="100" d:DesignWidth="536">
    <Button.Template>
        <ControlTemplate TargetType="{x:Type Button}">
            <Grid>
                <Grid Name="gridParent">
                    <Image Name="imgTransparent" Source="/MyApp;component/Resources/LeftCategoryTransparent.png" Stretch="Fill" Margin="0,0,0,0"  />
                    <Image Name="Part_Pressed" Source="/MyApp;component/Resources/PressedMainScreenSubMenu.png" Stretch="Fill" Margin="0,0,0,4"  Visibility="Hidden"/>
                    <Image Name="Focused" Source="/MyApp;component/Resources/MainSubMenuFocus.png" Margin="-3,0,-3,3"   Stretch="Fill" Visibility="Hidden" />
                    <Image Name="Seperator" Source="/MyApp;component/Resources/MainSubMenuSeperator.png" Margin="5,0,5,-1"   Stretch="Uniform" VerticalAlignment="Bottom"/>

                    <TextBlock Name="lblTitle" Text="{TemplateBinding Content}" HorizontalAlignment="Left"  Foreground="Gray" FontWeight="{TemplateBinding FontWeight}"   FontSize="24"  Margin="10" VerticalAlignment="Center" TextWrapping="WrapWithOverflow" TextAlignment="Left"/>
                </Grid>
            </Grid>
            <ControlTemplate.Triggers>
                <Trigger Property="IsPressed" Value="True">
                    <!--<Setter TargetName="Pressed" Property="Visibility" Value="Visible"/>-->

                </Trigger>
                <Trigger Property="IsFocused" Value="True">
                    <Setter TargetName="Focused" Property="Visibility" Value="Visible"/>
                    <Setter TargetName="lblTitle" Property="Foreground" Value="#f8cb1c" />
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Button.Template>
</Button>

In my application, I call web service and depending upon the no of items, i create button for each item and finally add these button in StackPanel. Its works well. Stakpanel layout is on left side in screenshot. Now problem is that when I run this application on different machine which have different Screen resolution (like 1920 *1200), then font size seems too small. So i want to adjust font size when container size change. One option is use ViewBox but in case of ViewBox all buttons seems like have different font size and TextWrapping is not possible.

So my actual requirement is that increase/decrease the textblock’s font size with TextWrapping and font size must be even for all buttons.

enter image description here

  • 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-06-03T23:47:40+00:00Added an answer on June 3, 2026 at 11:47 pm

    You can use a LayoutTransform based on the screen resolution, you can either scale up your stackpanel or scale up the whole window depending on the resolution.

    For the stackpanel:

    <StackPanel>
        <StackPanel.LayoutTransform>
            <ScaleTransform  x:Name="ScaleTransform" />
        </StackPanel.LayoutTransform>
        <Button>A</Button>
        <Button>B</Button>
        <Button>C</Button>
        <Button>D</Button>
    </StackPanel>
    

    Then bind the ScaleX and ScaleY to a formula based on the resolution. An example of this:

    double scale = System.Windows.SystemParameters.PrimaryScreenHeight / 720;
    //using 720p as the base screen height.
    
    this.ScaleTransform.ScaleX = scale;
    this.ScaleTransform.ScaleY = scale;
    

    You may want to do this in a ViewModel with some databinding if you are using MVVM.

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

Sidebar

Related Questions

I want to create a radio button custom control in my ASP MVC application.
I'm writing a custom camera application which follow this tutorial: http://marakana.com/forums/android/examples/39.html Now I'm able
Trying to get custom Done button in Utility Application Create new project in Xcode
I want to create custom button and I need it to be circle. How
I'm trying to create a custom button where the foreColor is always crimson and
I have to create a custom compound button bar control in Android like the
What is the easiest way to create a Silverlight Button with custom Content which
I'm trying to change the back button to a custom one. If I create
In a django application I have the following model: class Appointment(models.Model): #some other fields
I'm trying to create a PhoneGap application that in part, makes available a custom

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.