WPF Auto height in code

后端 未结 2 1322
孤街浪徒
孤街浪徒 2021-01-31 23:58

How could I set the value of the Height property of a WPF control in C# code to \"Auto\"?


    

        
2条回答
  •  南方客
    南方客 (楼主)
    2021-02-01 00:36

    Perhaps this link will help you.

    At times, you may want to programmatically set the Height or Width of a WPF element to Auto in code. To do this, just use the Double.NaN (Not a Number) value.

    For example, in C#:

    this.txtName.Width = Double.NaN;

提交回复
热议问题