当我尝试创建一个带有两个子元素的stackpanel并将其分配给飞行中时,为什么我的飞翔崩溃了



我正在尝试在GridView中右手敲击网格时尝试调用Callisto飞行(最终目标是允许用户更改值并存储在ApplicationDataContainer中)。我首先尝试使用一个示例来创建我在网上找到的菜单 - 可行的菜单,但我不想要菜单。因此,我尝试将其从菜单更改为带有文本块和文本框的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.g.i.cs:

if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();

顺便说一句,我最终可能会将此代码从右点的事件中移动到其在Charms设置中的"适当"位置,但我认为在任何一种情况下都需要解决此问题。

更新

我试图通过将飞行量从"插入"移动到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_rightpatpapped)中的一个网格,然后选择一个

,然后选择一个 ,然后访问setandSavesectionNames()的呼叫。

"更改n节的名称" textblocks或它们在设置面板上的任何内容,但是:crasho!

如果家伙想要在设置面板中有数十个设置,那么该如何工作 - 似乎没有比我添加的六个设置要多得多 - 它会在某个时候启动viewbox或scrollbox或其他东西来容纳这个?

例外可能是 notimplempledexception ,因为Callisto代码尚未实现 placementmode.mouse 选项。我今天有这个问题。

请参阅:https://github.com/timheuer/callisto/blob/master/src/src/callisto/controls/flyout/flyout/flyout/flyout.cs

case PlacementMode.Mouse:
    throw new NotImplementedException("Mouse PlacementMode is not implemented.");

最新更新