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

  • Home
  • SEARCH
  • 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 138765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:18:57+00:00 2026-05-11T07:18:57+00:00

Canvas doesn’t seem to play well together nicely with the other elements when you

  • 0

Canvas doesn’t seem to play well together nicely with the other elements when you try to build it into a layout and have e.g. controls on the side and the canvas is the drawing area.

For instance, why can I put a border around every element except a canvas? In the following code, border wraps canvas but the canvas only has the border on the top but not on the left, right or bottom:

<Window x:Class='WpfApplication25.Window1'     xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'     xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'     Title='Window1' Height='300' Width='300'>     <StackPanel>          <TextBlock DockPanel.Dock='Bottom' Text='Move the slider to reveal the answer:'/>         <Slider DockPanel.Dock='Bottom' Name='theSlider'              HorizontalAlignment='Left'              Width='200'              Minimum='0'              Maximum='1'              Value='1'              Cursor='Hand'/>          <Border BorderBrush='Tan' BorderThickness='2'>             <Canvas>                 <TextBlock Canvas.Left='45' Canvas.Top='50' Text='test' FontSize='16'/>                 <Rectangle                      Canvas.Left='10'                      Canvas.Top='10'                      Width='100'                      Height='100'                      Fill='Silver'                      Opacity='{Binding ElementName=theSlider, Path=Value}'                     />             </Canvas>         </Border>     </StackPanel> </Window> 
  • 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. 2026-05-11T07:18:58+00:00Added an answer on May 11, 2026 at 7:18 am

    From what I can tell in XamlPad, the problem appears to be that your Canvas does not have an explicit height/width, and that its HorizontalAlignment defaults to being in the middle of the Border. Without an explicit height and width the Border appears to collapse to 0 height and stretches on the width. My assumption is this is because your Border is in a StackPanel, as placing the Border in a Grid, causes it to behave as expected.

    Your best bet is to give the Canvas an explicit Height and Width. Not sure that is what you’re looking for though.

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

Sidebar

Related Questions

I have set a canvas' background to an image of a company logo. I
I have a main canvas 'blackboard' in a panel, this canvas has itself several
I have a canvas in Flex that shall be able only to be scrolled
I have a Canvas in a Flex application which has items inside it that
I have some Tkinter canvas and some picture of lines and text on it.
I have a canvas with user controls arranged on it. When a tooltip is
I am testing out canvas and video and I have read up on alot
I have a shell that contains a canvas, which in turn draws some text
I have an Image nested inside a Canvas. <mx:Canvas> <mx:Image source=@Embed(source='assets/library.swf', symbol='Waves') /> </mx:Canvas>
I am dynamically adding X canvas elements to a page via jQuery like so:

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.