I want to add the border off canvas using C# not XAML
How can i achieve it?
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.
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.
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);
You can simple create border canvas with DataBinding
on her Width
to MainCanvas.ActualWidth
and Height
to MainCanvas.ActualHeight
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With