开发者

How to capture current location (on canvas) of an MDIWindow, after it has been moved?

开发者 https://www.devze.com 2023-02-22 18:50 出处:网络
I have a Silverlight 4 app that has a canvas with five MDIWindows on it. The Canvas.Left and Canvas.Top properties are set in XAML. These five MDIWindows can be moved around with the mouse. I am tryin

I have a Silverlight 4 app that has a canvas with five MDIWindows on it. The Canvas.Left and Canvas.Top properties are set in XAML. These five MDIWindows can be moved around with the mouse. I am trying to use IsolatedStorageSettings to save their current location, invoked from a button event. However, when I call MDIWhatever.GetValue(Canvas.LeftProperty) I always get the initial value of Canvas.Left as set in XAML, and what I want is the current location. I've tried calling InvalidateArrange() and UpdateLayout() on both the MDIWindow and LayoutRoot (the canvas).

Private Sub btnSaveLayout_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnSaveLayout.Click

    MDIWhatever.InvalidateArrange()
    MDIWhatever.UpdateLayout()
    LayoutRoot.InvalidateArrange()
    LayoutRoot.UpdateLayout()

    _settings.Clear()
    _settings.Add("MDILeft", MDIWhatever.GetValue(Canvas.LeftProperty))
    _settings.Add("MDITop", MDIWhatever.GetV开发者_JAVA百科alue(Canvas.TopProperty))
    _settings.Save()

End Sub

This ought to be easy, what am I missing?

EDIT: This is a third-party control, from off of Codeplex. I assumed it was part of Silverlight because of the System.Windows.Controls namespace. I did not expect a third-party control to use this namespace instead of having its own.


Rather than get this one to work, I found another control that supports a Position property (that returns a Point object of the current position). FloatingWindowControl at http://jevgenijpankov.heliocode.com/articles/FloatingWindow.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消