I'm trying to invoke a Callisto Flyout when right-tapping on a grid in a GridView (the ultimate goal is to allow the user to change a value and store that in an ApplicationDataContainer). I first tried it with a sample that creates a menu that I found online -- that works, but I don't want a menu.So I tried changing it up from a menu to a StackPanel with a TextBlock and a TextBox on it. This code, though:
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();
}
...crashes and takes me to this line in App.g.i.cs:
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
BTW, I may eventually move this code from the RightTapped event to be in its presumably "proper" place in the Charms Settings, but I reckon this problem needs to be solved in either case.
UPDATE
I tried to go a different route with this by moving the flyout from "in place" to the Windows 8 Settings panel:
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();
}
However, the same thing happens - I can get to the call to SetAndSaveSectionNames() just fine by right-clicking one of the grids in my GridView (ItemView_RightTapped), and then selecting one of
the "Change the name of Section N" TextBlocks or whatever they are on the Settings panel, but then: crasho!
If a fella wants to have dozens of settings in the Settings panel, how will that work - it seems there's not room for much more than the six I added - will it sprout a ViewBox or ScrollBox or something at some point to accommodate this?