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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:02:35+00:00 2026-05-20T03:02:35+00:00

I need the following alignment For that I have created the xaml file as

  • 0

I need the following alignment

enter image description here

For that I have created the xaml file as follows,

<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
        <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
        <TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
    </StackPanel>

    <!--ContentPanel - place additional content here-->
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <ListBox ItemsSource="{Binding Collections}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="80"/>
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Image Grid.Column="0" Source="{Binding Icon}" HorizontalAlignment="Left" VerticalAlignment="Center" />
                        <Grid Grid.Column="1" HorizontalAlignment="Right" >
                            <Grid HorizontalAlignment="Stretch">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="0.600*" />
                                    <RowDefinition Height="0.400*" />
                                </Grid.RowDefinitions>
                                <TextBlock Grid.Row="0" Text="{Binding MainTextBlock}" VerticalAlignment="Center" />
                                <Grid Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="0.300*" />
                                        <ColumnDefinition Width="0.700*" />
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Grid.Column="0" Text="{Binding Value}" HorizontalAlignment="Left" VerticalAlignment="Center" />
                                    <TextBlock Grid.Column="1" Text="{Binding DateString}" HorizontalAlignment="Right" VerticalAlignment="Center" />
                                </Grid>
                            </Grid>
                        </Grid>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</Grid>

but I did not get the as expected result. what should i do for that? sub2 is always left aligned but actually we need it to be Right aligned.

Thanks in advance
dinesh

  • 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-20T03:02:36+00:00Added an answer on May 20, 2026 at 3:02 am

    I think the problem is with the nested grid elements that you’re using in your DataTemplate. You can simplify the visual tree and achieve the desired results by using a single Grid that has the column and row definitions and then use the Grid.ColumnSpan and Grid.RowSpan attached properties as shown in the following XAML:

    <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ShowGridLines="True">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="80"/>
            <ColumnDefinition Width="0.3*"/>
            <ColumnDefinition Width="0.7*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="0.6*"/>
            <RowDefinition Height="0.4*"/>
        </Grid.RowDefinitions>
        <Image
           Grid.RowSpan="2"
           HorizontalAlignment="Left"
           VerticalAlignment="Center"
           Source="{Binding Icon}"/>
        <TextBlock
           Grid.Column="1"
           Grid.ColumnSpan="2"
           Grid.Row="0"
           HorizontalAlignment="Center"
           VerticalAlignment="Center"
           Text="{Binding MainTextBlock}"/>
        <TextBlock
           Grid.Column="1"
           Grid.Row="1"
           HorizontalAlignment="Left"
           VerticalAlignment="Center"
           Text="{Binding Value}"/>
        <TextBlock
           Grid.Column="2"
           Grid.Row="1"
           HorizontalAlignment="Right"
           VerticalAlignment="Center"
           Text="{Binding DateString}"/>
    </Grid>

    To achieve list box items that stretch the full width of the ListBox you need to add an ItemContainerStyle that sets the HorizontalContentAlignment to Stretch. You can create a copy of the default style in Expression Blend, or use the following:

          <Style x:Key="FullWidthItemStyle" TargetType="ListBoxItem">
             <Setter Property="Background" Value="Transparent"/>
             <Setter Property="BorderThickness" Value="0"/>
             <Setter Property="BorderBrush" Value="Transparent"/>
             <Setter Property="Padding" Value="0"/>
             <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
             <Setter Property="VerticalContentAlignment" Value="Top"/>
             <Setter Property="Template">
                <Setter.Value>
                   <ControlTemplate TargetType="ListBoxItem">
                      <Border
                         x:Name="LayoutRoot"
                         HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                         VerticalAlignment="{TemplateBinding VerticalAlignment}"
                         Background="{TemplateBinding Background}"
                         BorderBrush="{TemplateBinding BorderBrush}"
                         BorderThickness="{TemplateBinding BorderThickness}">
                         <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                               <VisualState x:Name="Normal"/>
                               <VisualState x:Name="MouseOver"/>
                               <VisualState x:Name="Disabled">
                                  <Storyboard>
                                     <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="Background">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TransparentBrush}"/>
                                     </ObjectAnimationUsingKeyFrames>
                                     <DoubleAnimation
                                        Duration="0"
                                        Storyboard.TargetName="ContentContainer"
                                        Storyboard.TargetProperty="Opacity"
                                        To=".5"/>
                                  </Storyboard>
                               </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="SelectionStates">
                               <VisualState x:Name="Unselected"/>
                               <VisualState x:Name="Selected">
                                  <Storyboard>
                                     <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentContainer" Storyboard.TargetProperty="Foreground">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneAccentBrush}"/>
                                     </ObjectAnimationUsingKeyFrames>
                                  </Storyboard>
                               </VisualState>
                            </VisualStateGroup>
                         </VisualStateManager.VisualStateGroups>
                         <ContentControl
                            x:Name="ContentContainer"
                            Margin="{TemplateBinding Padding}"
                            Content="{TemplateBinding Content}"
                            ContentTemplate="{TemplateBinding ContentTemplate}"
                            Foreground="{TemplateBinding Foreground}"
                            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                            VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
                      </Border>
                   </ControlTemplate>
                </Setter.Value>
             </Setter>
          </Style>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following variable that I need to work with, and have to
I'd need advice on following situation with Oracle/PostgreSQL: I have a db table with
I have an assignment in which I need to create a function that tells
I have the following situation: There is a windows folder that has been mounted
Hey all, I have something of an interesting requirement for my project. I need
I need the following authentication script finished. I am weak at php/pdo so I
I need the following logic. If array contains value , return it else return
For a part of a program i need the following 2 methods. The first
I'm working on a project where I need the following. WCF service on the
Colleagues, Using JPA I need resolve following issue: at database level exits 3 entities

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.