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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:32:16+00:00 2026-05-21T23:32:16+00:00

I have a grid inside a canvas on a tab. The grid contains a

  • 0

I have a grid inside a canvas on a tab.
The grid contains a large bitmap image,
I have(tried to) bound the size of the grid to the size of the tab and also have a five pixel margin around the grid.

imageTab.cs

    public ImageTab(SendInfo sendInfo, int numImge, int numAccs)
    {
        imageDisplay = new ImageDisplay(sendInfo, numImge, numAccs);
        imageDisplay.ClipToBounds = true;
        CreateCanvas();
    }

    private void CreateCanvas()
    {
        Canvas canvas = new Canvas();
        canvas.Children.Add(imageDisplay);
        this.AddChild(canvas);
    }

ImageDisplay.xaml

<UserControl x:Class="MyProj.ImageDisplay">

      <Grid Margin="5,5,5,5" Height="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=TabControl, AncestorLevel=1}, Path=ActualHeight}">
          <Image/>
      </Grid>

</UserControl>

The grid comes off the bottom of the tab area slightly causing the bottom of the image to be cut off.
Is there a problem with my databinding, do I need to apply some sort of offset to it? (size of tab – 10pixels for the margin?)

  • 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-21T23:32:16+00:00Added an answer on May 21, 2026 at 11:32 pm

    You don’t need to set the Height property at all (also realize that it is incorrect to do so as you have it when you consider the 5 pixel margin, i.e., it would be off by 10 pixels).

    Just leave VerticalAlignment and HorizontalAlignment at their default values (which is Stretch) to get the effect you are after here.

    Try this on a new Window to see what I mean:

    <Window x:Class="WpfApplication9.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="438" Width="587" Background="Pink">
        <Grid Background="Black"  Margin="5">
    
        </Grid>
    </Window>
    

    The grid here will be black and will always stretch to the size of the window, using a 5 pixel margin which you will see because the Window’s back color is pink.

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

Sidebar

Related Questions

i currently have a textblock that is embedded in a large grid. I have
I have a ListBox with a ItemsPanelTemplate of Canvas. I know the ScrollViewer will
I have 9 items on a grid, I want all items to have 0.5
I have the following border in XAML: <Border Grid.Column=0 Grid.ColumnSpan=3 Grid.RowSpan=3 CornerRadius=1,1,1,1 Background=Red BorderBrush=#333333
I have a window that contains different functional areas of an account. The details,
In Silver light Tab control ,i have adding custom tab header (name along with
I have a grid control that I use throughout the application. I would like
I have seen this question asked a few times but I have not seen
I have an AJAX-enabled WCF service with the following signature: [OperationContract] [WebGet] public JQGridContract
I like 960 as an easy way of doing the layout of web sites.

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.