【发布时间】:2015-04-11 11:29:37
【问题描述】:
使用以下 XAML 代码:
<RelativePanel x:Name="MainPanel"/>
以及以下 C# 代码:
var _red = new Rectangle() {
Width = _res.X, Height = _res.Y / 2, Fill = new SolidColorBrush(Colors.Red)
};
var _blue = new Rectangle() {
Width = _res.X, Height = _res.Y / 2, Fill = new SolidColorBrush(Colors.Blue)
};
MainPanel.Children.Add(_red); MainPanel.Children.Add(_blue);
RelativePanel.SetAlignTopWithPanel(_red, true); // (a)
RelativePanel.SetAlignLeftWithPanel(_red, true); // (b)
RelativePanel.SetBelow(_blue, _red); // (c)
我有 2 个不同的例外:在 (a) 和 (b) 行,我有一个 AccessViolationException,以及附加信息:Attempted to read or write protected memory. This is often an indication that other memory is corrupt.。
在 (c) 行,所以如果我删除前两个,VS 的 JIT 调试器会告诉我 An unhandled win32 exception occured in foo.exe [10984]。这可能是一个错误代码,但我没有找到任何关于它的文档。
关于为什么会发生这种情况以及如何解决这个问题的任何线索?此外,如果我在 XAML 中设置这些属性,它就可以正常工作。
【问题讨论】:
-
我也遇到了同样的情况,但仅在电话中,在本地机器中有效:bit.ly/1JyD40j。我已经测试将它放在 Loaded 中,在 Dispatcher 中,但没有成功
-
确实我在 Universal Apps 的反馈应用中回复了,可能我应该选择 UI Frameworks 和 XAML
-
对我来说,问题发生在桌面(内部版本 10049)和手机(lumia 1520,v10.0.12534.56)中。我也在反馈表中报告了它,我希望这个问题能被尽快知道并纠正。
-
目前我能够在设计器中使用:RelativePanel.AlignLeftWith="{Binding ElementName=grid1}" 绑定而不是元素名称......粉碎。可能是这样,但我已经取得了其他任何成就。
-
对我来说,当我在设计器中设置属性时它总是有效,即使没有绑定。它只是不能通过代码工作。
标签: c# windows xaml windows-runtime win-universal-app