I want to add the border off canvas using C# not XAML
How can i achieve it?
I want to add the border off canvas using C# not XAML
How can i achieve it?
You can simple create border canvas with DataBinding
on her Width
to MainCanvas.ActualWidth
and Height
to MainCanvas.ActualHeight
I think you're better off by placing the canvas inside a border, then specify the border thickness in your codebehide. 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>
Codebehide:
// Turn on border
CanvasBorder.BorderThickness = new Thickness(1);
// Turn off border
CanvasBorder.BorderThickness = new Thickness(0);