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 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 a very simple webapp that runs within HTML5's Canvas that doesn't have
I have the following which doesn't work correctly: var canvas = new fabric.Canvas('canvas'); canvas.observe('mouse:down',
As far as I understand HTML5's canvas doesn't allow access to elements after they
I'm using Canvas.drawText which doesn't have any parameters for that. I have limited width
I have a problem that doesn't seem to have an easy answer, so if
In my HTML I have: <div id=cowcloud> <canvas id=cows width=1024 height=253> <p>Browser doesn't support
In the code below, the image imgNew doesn't show on the canvas when I
I've created a simple scene in three.js, but it doesn't works with canvas renderer
Starting to learn Canvas and have two classes so far (main one to call
I have a canvas element positioned absolutely over a Flash object of the same

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.