Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add border of canvas

I want to add the border off canvas using C# not XAML

How can i achieve it?

like image 890
Shashank Avatar asked Jun 09 '10 13:06

Shashank


People also ask

How do I add a border to a canvas in HTML?

A canvas is a rectangular area on an HTML page. By default, a canvas has no border and no content. Note: Always specify an id attribute (to be referred to in a script), and a width and height attribute to define the size of the canvas. To add a border, use the style attribute.

How do you put a border around text in Canva?

Search 'frames' or 'borders' in Canva to navigate different options. If you want to add a border around a section of text as seen in this example, use the Alt + Shift + B shortcut to add a solid line around your text.


2 Answers

I think you're better off by placing the canvas inside a border, then specify the border thickness in your code-behind. In your code you could then programmatically turn the border on and off.

XAML:

<Border x:Name="CanvasBorder" BorderBrush="Black">
    <Canvas>
        <!--Items here-->
    </Canvas>
</Border>

Code-behind:

// Turn on border
CanvasBorder.BorderThickness = new Thickness(1);

// Turn off border
CanvasBorder.BorderThickness = new Thickness(0);
like image 136
Brent Avatar answered Oct 07 '22 05:10

Brent


You can simple create border canvas with DataBinding on her Width to MainCanvas.ActualWidth and Height to MainCanvas.ActualHeight

like image 42
Svisstack Avatar answered Oct 07 '22 05:10

Svisstack