0

I have:

<Window x:Class="qq.MainWindow"
  ...
  Width="500"
  Height="300" 
>
...
<Canvas x:Name="gca" 
        Width="250"
        Height="150" />

This does not work

<Canvas x:Name="gca" 
        Width=Window.Width / 2
        Height="150" />

How do I assign the Canvas Width to equal half of the Window Width?

ttom
  • 985
  • 3
  • 12
  • 21
  • Out of curiosity, why do you want to use ``? It has very limited use in WPF/XAML - I understand it's intended as a transition path for WinForms devs who are used to using absolute coordinates. – Dai Oct 17 '21 at 12:56
  • 1
    I would put the Canvas in a UniformGrid with two rows and two columns. – Steeeve Oct 17 '21 at 12:57
  • XAML does not support inline C#-style expressions in XAML binding expressions - which is one of the many hurdles you'll encounter with XAML - I don't understand why Microsoft has still never addressed the major ergonomic pain-points with XAML for 15 years. – Dai Oct 17 '21 at 12:57

0 Answers0