Tuesday, April 5, 2011

TemplateBinding Height To owner height WPF

I want to set the height of the Template of the window to the owner height. Suppos if my main window has the 1280 and 1024 resolution then I want to get the 1024 height and set it to the border in the template. how can I access the main window height ?

From stackoverflow
  • It's a little difficult to understand what you want here. Perhaps your code would help.

    I am assuming, since you are talking about a template, you are creating a control. Is there a reason to actually need the height? I would think the easiest thing to do would be to set the default VerticalAligment to Stretch, and not worry about the actual height. If you needed the height, you could subscribe to the SizeChanged event of your control and get the value of the ActualHeight property.

    You could also get the height of a container window if you use FindAncestor in a RelativeSource binding.

    Asim Sajjad : I want to create template for the window. and I want the title and the body to the same which is given in the window lets says the window is 400 * 200 but i want the remaining space to be over lay just like the child window in the silverlight do. Hope you understand it
    Wonko the Sane : I'm sorry - I don't understand what you mean. When you say "template," do you mean WPF template? Or do you mean that you have a window with an area that stays constant and another area that changes content? Or.....? Again, some kind of example or code would be helpful.
    Asim Sajjad : I am talking about WPF Template.
    Wonko the Sane : I guess you'll have to post your code (or a generic version of it).

0 comments:

Post a Comment