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

The Archive Base Latest Questions

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

Probably I’m just missing something obvious, but I can’t get the image in my

  • 0

Probably I’m just missing something obvious, but I can’t get the image in my DataTemplate to align to the right in the Grid, so that when the window is stretched, the image is “pulled” to the right as well:

<Window.Resources>
    <DataTemplate x:Key="PersonTemplate" DataType="Minimal.Client.Person">
        <Border BorderBrush="Purple" BorderThickness="2" CornerRadius="2" Padding="5" Margin="5">
            <Grid Margin="10">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" MinWidth="200"/>
                    <ColumnDefinition Width="Auto" MaxWidth="200"/>
                </Grid.ColumnDefinitions>
                <StackPanel Grid.Column ="0" Orientation="Horizontal" >
                    <TextBlock FontFamily="Verdana" FontSize="16" FontWeight="Bold" Text="{Binding LastName}" />
                    <TextBlock FontFamily="Verdana" FontSize="16" Text=", " />
                    <TextBlock FontFamily="Verdana" FontSize="16" Text="{Binding FirstName}" />
                </StackPanel>
                <StackPanel Grid.Column="1" Orientation="Vertical" HorizontalAlignment="Right">
                    <Border BorderBrush="Black" BorderThickness="1">
                        <Image Source="{Binding Picture}" Width="180" Height="150" />
                    </Border>
                </StackPanel>
            </Grid>
        </Border>
    </DataTemplate>
</Window.Resources>

Any suggestions?

  • 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-14T03:23:34+00:00Added an answer on May 14, 2026 at 3:23 am

    I think the problem is that you have set a MaxWidth of 200 for the second column (where the Image is contained). Therefore, the column will not be any wider than 200 pixels and the two columns will not use the complete available space. If you insert another column in between the two columns and make this one star-sized, the Image will be right-aligned:

    <Grid Margin="10">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" MinWidth="200"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="Auto" MaxWidth="200"/>
        </Grid.ColumnDefinitions>
        <StackPanel Grid.Column ="0" Orientation="Horizontal" >
            <TextBlock FontFamily="Verdana" FontSize="16" FontWeight="Bold" Text="{Binding LastName}" />
            <TextBlock FontFamily="Verdana" FontSize="16" Text=", " />
            <TextBlock FontFamily="Verdana" FontSize="16" Text="{Binding FirstName}" />
        </StackPanel>
        <StackPanel Grid.Column="2" Orientation="Vertical" HorizontalAlignment="Right">
            <Border BorderBrush="Black" BorderThickness="1">
                <Image Source="{Binding Picture}" Width="180" Height="150" />
            </Border>
        </StackPanel>
    </Grid>
    

    This way, it works for me. However, you should be careful when using StackPanels. They always take as much space as they need. And if they are not given that much space, part of the content will simply be hidden.

    gehho.

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

Sidebar

Related Questions

Probably not the best wording for that question but... I understand there are things
Probably I'm doing something wrong but here it goes: I'm trying to create a
Probably a long question for a simple solution, but here goes... I have a
Probably an easy one: Are there any rules of thumb or pointers that could
This probably has a simple answer, but I must not have had enough coffee
This probably sounds really stupid but I have noo idea how to implement jquery's
Probably a simple question but I only have Linux to test this code on
Probably a dumb question but I'm new to MVC and jQuery. I want to
Probably a really simple one this - I'm starting out with C# and need
Probably not much more to elaborate on here - I'm using a NumericStepper control

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.