locked
Trigger Layoutupdate event when property change RRS feed

  • Question

  • I would like to trigger the layout update event of a particular control [ Say ControlX ]  when a property [ Say PropA ] changes. How can I do this in XAML.

    I have bound the PropA to width , height of several controls.In the SetMethod of PropA, I can access the ControlX and can call UpdateLayout method. But the problem is in the ArrangeOverride method of ControlX , I'm accessing the width and height of various controls. So it is still holding the old values. So I cannot use the UpdateLayout method in the Set method of PropA. How can I do?

    Friday, March 9, 2012 2:45 PM

Answers

  • Hi Syed,

    According to your description, I understand you are create a Custom Panel, and you want to bind controls width and height in it with a DP to resize these controls, right?

    If you need to resize the child controls, you should not set the specific size to controls in ArrangeOverride method, you can just set the position of child control.

    Here is a sample of create a custom control, and you can set width and height as you want for your reference:

    http://www.codeproject.com/Articles/37348/Creating-Custom-Panels-In-WPF

    If I misunderstand you, please feel free to let me know.

    Have a nice day.


    Annabella Luo[MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Annabella Luo Thursday, March 22, 2012 5:44 AM
    Thursday, March 15, 2012 5:28 AM

All replies

  • Hi Syed,

    According to your description, I understand you are create a Custom Panel, and you want to bind controls width and height in it with a DP to resize these controls, right?

    If you need to resize the child controls, you should not set the specific size to controls in ArrangeOverride method, you can just set the position of child control.

    Here is a sample of create a custom control, and you can set width and height as you want for your reference:

    http://www.codeproject.com/Articles/37348/Creating-Custom-Panels-In-WPF

    If I misunderstand you, please feel free to let me know.

    Have a nice day.


    Annabella Luo[MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Annabella Luo Thursday, March 22, 2012 5:44 AM
    Thursday, March 15, 2012 5:28 AM
  • We are temporarily marking this as "Answer", if you have any concerns or new findings; please feel free to let me know.
    Best regards.

    Annabella Luo[MSFT]
    MSDN Community Support | Feedback to us

    Thursday, March 22, 2012 5:44 AM