[英]Why is my flyout crashing when I try to create a StackPanel with two child elements and assign that to a Flyout?
我尝试在GridView中的网格上右击时调用Callisto Flyout(最终目标是允许用户更改值并将其存储在ApplicationDataContainer中)。 我首先用一个示例创建了一个可以在网上找到的菜单,但是我不想要菜单,因此尝试将其从菜单更改为带有TextBlock和TextBox的StackPanel。 这段代码:
private void ItemView_RightTapped(object sender, RightTappedRoutedEventArgs e)
{
var flyOut = new Flyout {PlacementTarget = sender as UIElement, Placement = PlacementMode.Mouse};
var sp = new StackPanel {MinWidth = 240, MinHeight = 80, Orientation = Orientation.Horizontal};
var tblk = new TextBlock {MinWidth = 60, MinHeight = 72};
sp.Children.Add(tblk);
TextBox tb = new TextBox {MinWidth = 120, MinHeight = 72};
sp.Children.Add(tb);
flyOut.Content = sp;
flyOut.IsOpen = true;
UpdateLayout();
}
...崩溃并带我到App.gics中的这一行:
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
顺便说一句,我最终可能会将代码从RightTapped事件移到“魅力设置”中的“适当”位置,但是我认为无论哪种情况都需要解决此问题。
我试图通过将弹出按钮从“就地”移动到“ Windows 8设置”面板来走不同的路线:
public ItemsPage()
{
InitializeComponent();
SettingsPane.GetForCurrentView().CommandsRequested += OnSettingsPaneCommandRequested;
}
private void ItemView_RightTapped(object sender, RightTappedRoutedEventArgs e)
{
SettingsPane.Show();
}
private void OnSettingsPaneCommandRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
{
args.Request.ApplicationCommands.Add(new SettingsCommand("commandSetSection1Name",
"Change the name of Section 1", SetAndSaveSectionNames));
args.Request.ApplicationCommands.Add(new SettingsCommand("commandSetSection2Name",
"Change the name of Section 2", SetAndSaveSectionNames));
args.Request.ApplicationCommands.Add(new SettingsCommand("commandSetSection3Name",
"Change the name of Section 3", SetAndSaveSectionNames));
args.Request.ApplicationCommands.Add(new SettingsCommand("commandSetSection4Name",
"Change the name of Section 4", SetAndSaveSectionNames));
args.Request.ApplicationCommands.Add(new SettingsCommand("commandSetSection5Name",
"Change the name of Section 5", SetAndSaveSectionNames));
args.Request.ApplicationCommands.Add(new SettingsCommand("commandSetSection6Name",
"Change the name of Section 6", SetAndSaveSectionNames));
}
private void SetAndSaveSectionNames(IUICommand command)
{
var flyOut = new Flyout(); // flyOut is a Callisto control
var sp = new StackPanel {MinWidth = 240, MinHeight = 80, Orientation = Orientation.Horizontal};
var tblk = new TextBlock {MinWidth = 60, MinHeight = 72};
sp.Children.Add(tblk);
TextBox tb = new TextBox {MinWidth = 120, MinHeight = 72};
sp.Children.Add(tb);
flyOut.Content = sp;
flyOut.IsOpen = true;
UpdateLayout();
}
但是,发生了相同的事情-通过右键单击GridView中的一个网格(ItemView_RightTapped),然后选择其中一个,可以很好地调用SetAndSaveSectionNames()。
“更改N部分的名称”文本块或“设置”面板上的任何文本块,然后:crasho!
如果一个小伙子想要在“设置”面板中有几十个设置,那将如何工作-似乎没有比我添加的六个更多的空间-它会在某个时候萌发一个ViewBox或ScrollBox或其他东西来容纳它吗?
异常可能是NotImplementedException,因为Callisto代码尚未实现PlacementMode.Mouse选项。 我今天有这个问题。
参见: https : //github.com/timheuer/callisto/blob/master/src/Callisto/Controls/Flyout/Flyout.cs
case PlacementMode.Mouse:
throw new NotImplementedException("Mouse PlacementMode is not implemented.");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.