.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

How to align two TextBlocs in StackPanel

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :JQuery


how can I allign two TextBlocks of different font size and weight in Stackpanel horizontally so that they are centered in horizontal direction.
With the following XAML code the the horizontal center of text 1 lays not on the same "line" as the horizontal center of text 2.

<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
            <TextBlock VerticalAlignment="Center" FontSize="18" FontWeight="Bold">Project :</TextBlock>
            <TextBlock VerticalAlignment="Center" FontSize="12" Margin="3">Hugo</TextBlock>

Thanks for hints and help.


View Complete Post

More Related Resource Links

Align spans vertically and horizontally inside a div



This question is not really about ASP.Net, but since almost all ASP.Net developers know css, I am sure someone will have answer. I have the following html and inline css:

<div id="container" style="height: 34px; width: 100%; border:1px solid #333">
<span id="largeText" style="font-size: 22px">Large text</span>
<span id="smallText" style="font-size: 12px">Small text</span>

I want to
(1) Vertically align both largeText and smallText in container div
(2) Horizontally largeText will be attached to the left border of container div  and smallText will be attached to the right.

Please help

How can I align Left the text into a Button?

I've tried: Code Snippet Button button = new Button(); button.Width = 200; TextBlock textBlock = new TextBlock(); textBlock.Text = "Aligned text" textBlock.TextAlignment = TextAlignment.Left; button.Content = textBlock;   but it is not working.

How to align text to top position on Ribbon buttons?

Hello SharePoint Experts, I have a custom masterpage which is derived from v4.master and it uses the default SP Foundation 2010 Ribbon. As you all know,the default Ribbon buttons such as New Document,Upload Document,Alert Me,etc, have text at the bottom below the icons. Ribbon buttons such as CheckOut,CheckIn,etc have their text aligned to the right of the icons. My requirement is to have all the text on Ribbon groups and buttons aligned to the top such that the image is below the text.(By default it is the other way round). I tried manipulating the CMDUI.XML file located at 14\TEMPLATE\GLOBAL but no use. I also tried overriding the Ribbon CSS(from COREV4.CSS) but it was of no use as well. Does anyone have inputs on how to get this done? Any help is appreciated. Thanks.Regards, Gautam Kaikini, MCTS WSS 3.0 Application Development.

How do I make a RadioButton's Bullet align top

I have a RadioButton with two textblocks inside is. <RadioButton> <StackPanel> <TextBlock Text="{x:Staticprop:Resources.PrimaryInstallation}" TextWrapping="Wrap" /> <TextBlock Text="{x:Staticprop:Resources.PrimaryInstallationDescription}" TextWrapping="Wrap" Foreground="DimGray" /> </StackPanel> </RadioButton> Now the RadioButtons' buttet is aligned in the center of the text, but I want it to the top, VerticalAlignment top etc does not work, how do I do this note: I want the whole text to be aligned with the radiobuttons text and trigger the radiobutton to be checked so thats why I placed it inside it

Align 3 Tables in Master Page

I'm using VS 2008. I have 3 tables in my master page. I wish to align all 3 tables with 140px from the left and 140px from the right. What are the properties or attributes I need to set for the 3 tables to achieve this? I have tried using Left 140px Right 140px for all tables but didn't work. Below is my master page for the 3 tables so far and you will see that I have only manged to get the bottom (3rd table) to mopve 140px from the left.   <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MyCompanyMaster.master.cs" Inherits="MyCompanyMaster" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <title></title>    <asp:ContentPlaceHolder id="head" runat="server">    </asp:ContentPlaceHolder>    <style type="text/css">        .style1        {            width: 118px;        }    </style></head><body> &

How to align data in Chart legend in SSRS 2008?

Hi,I have created a chart of type 3D pie.  I put a String field for Category and Sum(numeric field) for Data.I wanted to show the legend as Category field and Data field and it's displaying as i set.Now how to make alignment of Data in legend, so that my numeric fields should align Right and String field should align Left.  I can make whole legend alignment but I want to make only the numeric field in the legend to align Right.Is it possible or there any work around?Please let me know.

Right align image in header with matrix in body

I need to have a logo image right aligned in the header, yet the body of the report consists of a matrix that fills the report horizontally. The page size is 11in / 8.5in, yet the designed size is 5in wide, because the matrix takes up this amount. If I increase the design width to 11, I get blank pages because I believe that the matrix it pushing to page to overflow. Leaving the design width to 5, I place the logo in the upper right, when previewd, it is fixed in this position, in the center of the header. How can I get the image to flow and right align and follow to the end of the matrix on the page? I have tried placing it in a text box, but this does not work. I have tried to pad the image, and that does not work either. Is there an expression that can be used to align this to the right? TIA Rick

Binding Content to a Stackpanel

Hello I have a class where I instantiate a couple auf buttons which I would like to display in a stackpanel. I use this class a lot in the XAML file (its my Datacontext). How Do I manage it that I can use a kind of collection in the class so that these buttons show up in the stackpanel ? kind regards Lorenz

Vertical Align Menu Items when RenderingMode=List


I am having problems getting my Menu Items to align vertically in the middle when I set my rendering mode = list.

aspx code

        <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" 
            RenderingMode="list" CssClass="AspNet-Menu">
                <asp:MenuItem NavigateUrl="#" Text="Menu 1" Value="Menu 1"></asp:MenuItem>
                <asp:MenuItem NavigateUrl="#" Text="Menu 2" Value="Menu 2"></asp:MenuItem>
                <asp:MenuItem NavigateUrl="#" Text="Menu 3" Value="Menu 3"></asp:MenuItem>

css code for list

/* MENU */

.AspNet-Menu ul li{ width:60px; height:30px; background-color:Silver; vertical-align:middle;}
.AspNet-Menu ul li a
	color: Red;

But if i set the rendering mode to table it works fine...

aspx code

        <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" 
            RenderingMode="table" CssClass="AspNet-Menu">

Table td align center with width problem


Hi, can you please tell me why the alignment isn't working:


<table border="1" width="700px">
            <td align="center" width="14px">
1 </td> <td align="center" width="14px">
<td align="center" width="14px"> 3 </td> <td align="center" width="14px"> 4 </td> <td align="center" width="14px"> 5 </td> </tr> </table>


but when i remove the width from all the tds, the align will work.


Creating a fly up Storyboard on a stackpanel


Basically i have a few buttons in a stackpanel on the bottom of the page and when my mouse is over them i want the buttons to gradually come up.

Anyone know how to achieve this?

This is what i have tried

<StackPanel x:Name="ControlsStackPanel" Grid.Row="5" Margin="0,0,10,10" VerticalAlignment="Bottom" HorizontalAlignment="Right" Orientat

Right Align Image in Report Header

I have a report with an image in the header that I would like aligned along the right edge of the tablix, but the image always renders from the left edge of the image placeholder. How can I force it to render from the right edge? It needs to be somewhat dynamic as I'm passing in the image conditionally.
"A bus station is where a bus stops. A train station is where a train stops. On my desk I have a workstation..."

label, dropdown list and linkbutton not align in a row, linkbutton 'drop' down.

i have a label 'status' , a dropdownlist and a linkbutton
they are align in a row, but notice that the linkbutton is 'drop' down to second row despite there's a space after.
<div style="float:left;width:297px">
                            Status  :     
                            <asp:DropDownList ID="ddlstatus" DataTextField="typename" DataValueField="id" runat="server">
                                <asp:LinkButton ID="lbSearchApproval" runat="server" CssClass="btnSmall" onclick="lbSearchApproval_Click" 


Datagrid CellStyle vertical align problem


Im using the WPF toolkit when I set a textcolum cell style to align the text to the center vertically it becomes very hard to select the text

without the cellstyle I can just click anywhere in the cell and begin editing the text in there, but with the cellstyle you have a very limited area in the cell where you can select the text field

does anyone have any way to fix this?

                      <Style TargetType="{x:Type dg:DataGridCell}">
                          <Setter Property="VerticalAlignment" Value="Center"></Setter>

Adding an Image to a StackPanel dynamically


I feel silly asking this, but so far I haven't been able to solve this problem by myself, so here goes.

I'm trying to dynamically add a StackPanel to a Canvas, which works, but I also need to add an Image to the same StackPanel, which does not yet work. My code for this looks like this:

public void CreateInfo()
  StackPanel info = new StackPanel();
  TextBlock authorBlock = new TextBlock();
  TextBlock extraBlock = new TextBlock();

  info.Height = 500;
  info.Width = 500;

  authorBlock.Text = "Some text to test.";

  System.Windows.Controls.Image img = new System.Windows.Controls.Image(); // I needed to disambiguate Image.
  img.Source = new BitmapImage(new Uri("/Trex;component/Resources/icons/fire.png", UriKind.RelativeOrAbsolute)); // fire.png is something like 24 x 44 pixels.

  Canvas.SetLeft(info, 100);

Why wont my numbers in my grid align to the right


Here is my grid code: the amt column wont align to the right :(

<asp:GridView ID="gvNoAnnData" runat="server" AutoGenerateColumns="False"
            AllowSorting="True" BackColor="White" BorderColor="#999999" BorderStyle="None"
            BorderWidth="1px" CellPadding="2" GridLines="Vertical" Width="80%">
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White"
HorizontalAlign="left" />
                <asp:BoundField DataField="fNo" HeaderText="F #" SortExpression="fNo"
                    InsertVisible="False" ReadOnly="True" Visible="true" >

not using tables: how do i align two columns, with textboxes, labels, dropdownlists, radiobuttonlis


problems with my CSS:


the Address (line 2) textbox ,City textbox, State dropdownlist and Zipcode textbox are vertically cramped (not equally spaced apart). 

the City label, State Label, and Zipcode labes are not horizontally aligned.

the Contact Type label and the Email Address label are not horizontall aligned. 



<asp:TabPanel ID="tpAdd" runat="server" HeaderText="Add" >
                <div id="wrapper">
		<div id="content">

			<div id="left">

				<!-- 	use a container to avoid using padding and border on #left
						which causes cross-browser inconsistencies with width -->
				<div class="left-container"><br />
                <p style="margin-left: 40px">
                    <asp:Label ID="lblFirstName" runat="server" Text="First Name:"></asp:Label>
                    <asp:TextBox ID="tbFirstName" runat="server" CssClass="txtbox"></asp:TextBox>
                    <br />
                    <asp:Label ID="lblLastName" runat="server" T
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend