如何在移动 MDIWindow 后捕获其当前位置(在画布上)?
我有一个 Silverlight 4 应用程序,其画布上有五个 MDIWindows。 Canvas.Left 和 Canvas.Top 属性在 XAML 中设置。这五个 MDIWindows 可以用鼠标移动。我正在尝试使用 IsolatedStorageSettings 来保存从按钮事件调用的当前位置。但是,当我调用 MDIWhatever.GetValue(Canvas.LeftProperty) 时,我总是得到 XAML 中设置的 Canvas.Left 的初始值,而我想要的是 当前位置。我尝试在 MDIWindow 和 LayoutRoot (画布)上调用 InvalidateArrange() 和 UpdateLayout() 。
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.GetValue(Canvas.TopProperty))
_settings.Save()
End Sub
这应该很容易,我错过了什么?
编辑:这是来自 Codeplex 的第三方控件。由于 System.Windows.Controls 命名空间,我认为它是 Silverlight 的一部分。我没想到第三方控件会使用这个命名空间而不是拥有自己的命名空间。
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.GetValue(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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有让这个控件工作,而是找到了另一个支持 Position 属性(返回当前位置的 Point 对象)的控件。 FloatingWindowControl 位于 http://jevgenijpankov.heliocode.com/articles/FloatingWindow.aspx
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