コード例 #1
0
        /// <summary>
        /// Show a <see cref="MessageDialog"/>
        /// </summary>
        ///
        /// <param name="grid">Grid to use</param>
        /// <param name="dialogSettings"><see cref="DialogSettings"/> of the <see cref="MessageDialog"/></param>
        /// <param name="itemSource">Item to set in the combo box</param>
        ///
        /// <returns>
        /// <see cref="object"/> which depend of the seleccted item
        /// </returns>
        public static async Task <object> ShowSelectDialog(Grid grid, DialogSettings dialogSettings, IEnumerable itemSource)
        {
            // Create the message dialog
            SelectDialog selectDialog = new SelectDialog(dialogSettings);

            dialogLoaded = selectDialog;
            grid.Children.Add(selectDialog);

            // Set the item source
            selectDialog.SelectComboBox.ItemsSource   = itemSource;
            selectDialog.SelectComboBox.SelectedIndex = 0;

            // Wait the message result and return it
            await selectDialog.WaitMessageResult();

            return(selectDialog.SelectComboBox.SelectedItem);
        }
コード例 #2
0
        /// <summary>
        /// Show a <see cref="MessageDialog"/>
        /// </summary>
        ///
        /// <param name="window">Window to use</param>
        /// <param name="dialogSettings"><see cref="DialogSettings"/> of the <see cref="MessageDialog"/></param>
        /// <param name="itemSource">Item to set in the combo box</param>
        ///
        /// <returns>
        /// <see cref="object"/> which depend of the seleccted item
        /// </returns>
        public static async Task <object> ShowSelectDialog(this XUiWindow window, DialogSettings dialogSettings, IEnumerable itemSource)
        {
            // Create the message dialog
            SelectDialog selectDialog = new SelectDialog(dialogSettings);

            dialogLoaded = selectDialog;
            Grid grid = window.Template.FindName("DialogContainer", window) as Grid;

            grid.Children.Add(selectDialog);

            // Set the item source
            selectDialog.SelectComboBox.ItemsSource   = itemSource;
            selectDialog.SelectComboBox.SelectedIndex = 0;

            // Wait the message result and return it
            await selectDialog.WaitMessageResult();

            return(selectDialog.SelectComboBox.SelectedItem);
        }