Two way binding on Window.Top with MultiBinding with Converter not working


  • I would like to bind to the Window.Top value, however I needed the height in my converter so I tried MultiBinding

    The window has the Name "control" specified and a Property TopValue is available in the DataContext


                    <localConverters:MultiConverter />
                        Mode="TwoWay" />
                        Mode="OneWay" />

    The window is placed on the correct top value, the Convert method is called correctly.


    This is my problem: after dragging the window (or closing it), the ConvertBack method is not called, so two way binding is not working properly.

    When I apply this MultiBinding with converter to a TextBox, the ConvertBack method is called when focus is lost, so it does work like expected, only not on the Window.Top property.

    What is wrong?

    Friday, December 30, 2011 7:14 AM


  • Hi Vincent,

    Yes, as far as I know, the bindings on Window.Top (and also other sizing properties of the Window) will be cleared when you move/resize the Window, so you cannot use Binding to update the position/size of the a Window.

    I suggest you to use an attached property for databinding and update the Window.Top when that attached property changes.

    Best regards,

    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Monday, January 02, 2012 3:26 AM
  • Solved this using a behavior, setting the left and top to the viewmodel when the window gets closed.


    Monday, January 02, 2012 10:11 AM

All replies