Dialogs

Resides in the namespace FasterWPF.Dialogs in the DialogHelpers static class.

These dialogs are implemented as panels on a Canvas in order to support Single-Page-Applications (SPA). In other words, the dialogs will not launch a brand new Win32 Window. If your top-level Window inherits from CPSBaseWindow, it will automatically have a base.Canvas that you may leverage for the purpose of Dialogs.

These dialogs are "modal" in a way, within the app; for instance, even if you switch between tabs the OK Dialog will continue to display on top. However, the dialog is not modal across or outside of its own window / single-page-application. It stays within the container of its parent Canvas

You may likely need to manually disable any controls underneath the dialog, as desired. The Selectors engine may be helpful with this task.

For convenience, I have supplied a DialogHelpers class for displaying:
1. OK Dialogs
2. Yes-No-Cancel Dialogs
3. QuestionBox Dialogs
4. Combo Editor Dialogs
5. ListBox Dialogs
6. CustomFormDialogs

(Eventually, it would be nice to also support FileBrowse, DirectoryBrowse, ImageBrowse, and ProgressBar. Perhaps, in a later version.)

See examples below . . .

OK Dialog

OKDialogs.png

using FasterWPF.Dialogs;

Canvas canVas = (Canvas)Application.Current.Properties["Canvas"];
string dialogGuid ="3c9275d4-42fe-4702-b081-9964de774387";

FasterWPF.Dialogs.DialogHelpers.ShowOKDialog(canVas, dialogGuid , "hello", 297.0D, 35.0D, 300.0D, Brushes.Black, new Thickness(1), Brushes.LightSteelBlue, Brushes.Gray, Brushes.White, Brushes.White, Brushes.Blue, true); 



Yes No Cancel Dialog

YesNoDialog.png

using FasterWPF.Dialogs;

Canvas canVas = (Canvas)Application.Current.Properties["Canvas"];
string dialogGuid ="3c9275d4-42fe-4702-b081-9964de774387";

FasterWPF.Dialogs.DialogHelpers.ShowYesNoCancelDialog(canVas2, Application.Current.Properties["DialogGuid"].ToString(), "Bind via Selector Class Example", 175.0D, 150.0D, 150.0D, Brushes.Black, new Thickness(1), Brushes.Silver, Brushes.WhiteSmoke, Brushes.White, Brushes.Silver, Brushes.Gray, true,
result => {
// . . . do something with result boolean . . . true for Yes, false for No . . .   ; 
});



Question Box Dialog

QuestionDialog.png

Starting with the Question Box Dialog, I introduced the concept of TitleSettings and LabelSettings in order to better group the parameters for the Title settings and the "body" settings respectively. The Question Box is a dialogbox with a single label for asking a question above a single Text Box (to allow the user to provide an answer.)

using FasterWPF.Dialogs;

Canvas canVas = (Canvas)Application.Current.Properties["Canvas"];
string dialogGuid ="3c9275d4-42fe-4702-b081-9964de774387";

TitleSettings ts = new TitleSettings() { TitleCaption = "My Question", TitleMargin = new Thickness(1), TitleBackground = Brushes.Navy, TitleForeground = Brushes.White, TitleHeight = 30.0D, TitleFontSettings =new FontSettings() { FontFamily = "Arial", FontSize = 12.0, FontStyle = FontStyles.Normal, FontWeight = FontWeights.Bold }  };

LabelSettings ls = new LabelSettings() { LabelCaption = "How did the chicken get across the road?", LabelMargin = new Thickness(4.0, 0.0, 10.0, 2.0), LabelMinWidth = 297.0D, LabelForeground = Brushes.Black, LabelBackground = Brushes.LightSteelBlue, LabelFontSettings = new FontSettings() { FontFamily = "Arial", FontSize = 12.0, FontStyle = FontStyles.Italic, FontWeight = FontWeights.Normal } };
                 
FasterWPF.Dialogs.DialogHelpers.ShowQuestionBoxDialog(canVas, dialogGuid, 297.0D, 35.0D, 300.0D, 170.0D, 300.0D, 150.0D, Brushes.Black, new Thickness(1), Brushes.LightSteelBlue, ts, ls, "It walked.", new Thickness(4.0, 0.0, 10.0, 4.0), Brushes.Gainsboro, 50, Brushes.AliceBlue, Brushes.Black, Brushes.WhiteSmoke, true, Helpers.SetFocus.Delayed, 3, answer => { MessageBox.Show(answer); },
 answer => { 
// . . . do something with answer string . . .   ; 
}, answer => { 
// . . . do something that will always run on close of the dialog . . .   ; 
 });



Combo Editor Dialog

ComboDialog1.png
ComboDialog2.png

The combo editor dialog adds yet another parameter called ComboBoxSettings as well as an optional ApplyComboBoxStrategy method that may override even more of the default Aero settings for the Combo Editor.

The ComoBoxSettings allows you to define the number of rows to display in the ComboBoxItem within the dropdown of the editor. The options are Helpers.ItemTextRows.OneRowOfText OR Helpers.ItemTextRows.TwoRowsOfText. For instance, there are two rows in the sample image above.

The combo editor dialog also provides for a SelectionChanged action.

using FasterWPF.Dialogs;

Canvas canVas = (Canvas)Application.Current.Properties["Canvas"];
string dialogGuid ="3c9275d4-42fe-4702-b081-9964de774387";

ComboBoxSettings cs = new ComboBoxSettings() { ComboItemMinWidth=257D, ComboItemBorderColor = Brushes.Blue, ComboBoxStyle = ComboStyles.TypeAheadButCannotSelectOrCopyText, ComboItemBorderThickness= new Thickness(0D,0D,0D,1D), ComboItemTextRows= Helpers.ItemTextRows.TwoRowsOfText, ScrollViewerWidth=150D, ScrollViewerBackgroundColor="Gainsboro", ScrollViewerPressedColor="Silver", ScrollViewerMouseOverColor="White", HighlightBackgroundColor=Brushes.AliceBlue, HighlightForegroundColor=Brushes.Black, ScrollViewerHeight=150D };
               
TitleSettings ts = new TitleSettings() { TitleCaption = "My Question", TitleMargin = new Thickness(1), TitleBackground = Brushes.Navy, TitleForeground = Brushes.White, TitleHeight = 30.0D, TitleFontSettings =new FontSettings() { FontFamily = "Arial", FontSize = 12.0, FontStyle = FontStyles.Normal, FontWeight = FontWeights.Bold }  };

LabelSettings ls = new LabelSettings() { LabelCaption = "How did the chicken get across the road?", LabelMargin = new Thickness(4.0, 0.0, 10.0, 2.0), LabelMinWidth = 297.0D, LabelForeground = Brushes.Black, LabelBackground = Brushes.LightSteelBlue, LabelFontSettings = new FontSettings() { FontFamily = "Arial", FontSize = 12.0, FontStyle = FontStyles.Italic, FontWeight = FontWeights.Normal } };
                 
FasterWPF.Dialogs.DialogHelpers.ShowComboBoxDialog(canVas, dialogGuid, 297.0D, 35.0D, 300.0D, 170.0D, 300.0D, 150.0D, Brushes.Black, new Thickness(1), Brushes.LightSteelBlue, cs, ts, ls, "Blue", new Thickness(4.0, 0.0, 10.0, 4.0), Brushes.Gainsboro, Brushes.AliceBlue, Brushes.Black, Brushes.WhiteSmoke, true, Helpers.SetFocus.Delayed, 3,
 comboBx =>
{

//OPTIONALLY override the Aero highlight and selected color for Combo Editor
//comboBx.ApplyComboBoxStrategy("20", "White", "Gold", true, "LawnGreen", "Gold", "Gold", "Black", "Orange", "M 1,4.5  L 4.5,1  L 8,4.5", "Blue", "Red", "Gray");

comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Blue").AddText(1, 0, "Blue as water.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Red").AddText(1, 0, "Red as apple.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Green").AddText(1, 0, "Green as grass.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Orange").AddText(1, 0, "Orange as pumpkin.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Yellow").AddText(1, 0, "Yellow as taxicab.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Purple").AddText(1, 0, "Purple as grape.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Brown").AddText(1, 0, "Brown as dirt.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Black").AddText(1, 0, "Black as midnight.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
 },
(Object o1, SelectionChangedEventArgs ev1) =>
{
// . . . do something with SelectedItem on firing of Selected Changed Event . . .   ; 
MessageBox.Show("ComboBox Selected Changed: " + (((ComboBox)ev1.Source).SelectedItem).Cast<Border>().GetText<ComboBox>(0, 0).ToString());

}, answer => {
// . . . do something on OK click . . .   ; 
 }, 
answer => { 
// . . . do something on CANCEL click . . .   ; 
 }, 
answer => { 
// . . . do something that will always run on close of the dialog . . .   ; 
 });



List Box Dialog

listBoxDialog.png

The List Box Dialog allows you to define custom ListBoxSettings in addition to Title and Label Settings. It also contains the option for either Helpers.ItemTextRows.OneRowOfText OR Helpers.ItemTextRows.TwoRowsOfText in the ListBoxItem.

using FasterWPF.Dialogs;

Canvas canVas = (Canvas)Application.Current.Properties["Canvas"];
string dialogGuid ="3c9275d4-42fe-4702-b081-9964de774387";

ListBoxSettings lSettings = new ListBoxSettings() {  HighlightForegroundColor="Navy", ItemHeight = 21, ScrollViewerPressedColor = "LightSteelBlue", HighlightBackgroundColor="SeaShell", ScrollViewerBackgroundColor="Silver", ScrollViewerMouseOverColor="Navy", Height=145.0D, Width=155.0D, ItemBorderThickness = new Thickness(0D, 0D, 0D, 2D), ItemTextRows = Helpers.ItemTextRows.TwoRowsOfText, ItemMinWidth = 150D,  ItemBorderColor = Brushes.Black};

TitleSettings ts = new TitleSettings() { TitleCaption = "My Question", TitleMargin = new Thickness(1), TitleBackground = Brushes.Navy, TitleForeground = Brushes.White, TitleHeight = 30.0D, TitleFontSettings =new FontSettings() { FontFamily = "Arial", FontSize = 12.0, FontStyle = FontStyles.Normal, FontWeight = FontWeights.Bold }  };

LabelSettings ls = new LabelSettings() { LabelCaption = "How did the chicken get across the road?", LabelMargin = new Thickness(4.0, 0.0, 10.0, 2.0), LabelMinWidth = 297.0D, LabelForeground = Brushes.Black, LabelBackground = Brushes.LightSteelBlue, LabelFontSettings = new FontSettings() { FontFamily = "Arial", FontSize = 12.0, FontStyle = FontStyles.Italic, FontWeight = FontWeights.Normal } };

FasterWPF.Dialogs.DialogHelpers.ShowListBoxDialog(canVas, dialogGuid, 297.0D, 44.0D, 135.0D, 300.0D, 320.0D, 300.0D, 150.0D, Brushes.Black, new Thickness(3), Brushes.LightSteelBlue, lSettings, ts, ls, "1", new Thickness(4.0, 0.0, 10.0, 4.0), Brushes.Gainsboro, Brushes.AliceBlue, Brushes.Black, Brushes.WhiteSmoke, true, Helpers.SetFocus.Delayed, 3,
listBx =>
{
listBx.BeginComposite<ListBox>("1").AddText(0, 0, "Blue").AddText(1, 0, "Blue as water.").EndComposite<ListBox, ListBoxArgs>(new ListBoxArgs());
listBx.BeginComposite<ListBox>("2").AddText(0, 0, "Red").AddText(1, 0, "Red as apple.").EndComposite<ListBox, ListBoxArgs>(new ListBoxArgs());
listBx.BeginComposite<ListBox>("3").AddText(0, 0, "Green").AddText(1, 0, "Green as grass.").EndComposite<ListBox, ListBoxArgs>(new ListBoxArgs());
listBx.BeginComposite<ListBox>("4").AddText(0, 0, "Orange").AddText(1, 0, "Orange as pumpkin.").EndComposite<ListBox, ListBoxArgs>(new ListBoxArgs());
listBx.BeginComposite<ListBox>("5").AddText(0, 0, "Yellow").AddText(1, 0, "Yellow as taxicab.").EndComposite<ListBox, ListBoxArgs>(new ListBoxArgs());
listBx.BeginComposite<ListBox>("6").AddText(0, 0, "Purple").AddText(1, 0, "Purple as grape.").EndComposite<ListBox, ListBoxArgs>(new ListBoxArgs());
listBx.BeginComposite<ListBox>("7").AddText(0, 0, "Brown").AddText(1, 0, "Brown as dirt.").EndComposite<ListBox, ListBoxArgs>(new ListBoxArgs());
listBx.BeginComposite<ListBox>("8").AddText(0, 0, "Black").AddText(1, 0, "Black as midnight.").EndComposite<ListBox, ListBoxArgs>(new ListBoxArgs());
},
(Object o1, SelectionChangedEventArgs ev1) =>
{
// . . . do something with SelectedItem on firing of Selected Changed Event . . .   ; 
MessageBox.Show("ListBox Selected Changed: " + (((ListBox)ev1.Source).SelectedContentControl().GetTextRuns<Grid, ListBox>().FirstOrDefault()));

 }, answer => {
// . . . do something on OK click . . .   ; 
}, 
answer => { 
// . . . do something on CANCEL click . . .   ; 
}, answer => { 
// . . . do something that will always run on close of the dialog . . .   ; 
});


Custom Form Dialog

The Custom Form Dialog allows you to insert your own Custom panel into the standard Dialog with its X in the upper right hand corner and OK button in the lower right hand corner.

The List Box Dialog is itself implemented via the Custom Form Dialog method; consequently, the code for List Box Dialog may be the best, ready example for this.

NOTE #1: there is code at the end to tab into the List Box to set focus to it based on a slight delay (in seconds)
NOTE #2: there is code to capture and wire up both the ESC and the ENTER key.

/// <summary>
/// Display a ListBox Dialog. Will NOT display if another dialog with the SAME dialogGuid is already displaying. buildFormAction contains StackPanel for body, okButton Border, cancelButton Border, and title Label.
/// </summary>
/// <param name="canVas"></param>
/// <param name="dialogGuid"></param>
/// <param name="width"></param>
/// <param name="internarlGridRowHeight"></param>
/// <param name="borderWidth"></param>
/// <param name="borderHeight"></param>
/// <param name="left"></param>
/// <param name="top"></param>
/// <param name="dialogBoxBorder"></param>
/// <param name="dialogBoxBorderThickness"></param>
/// <param name="borderBackground"></param>
/// <param name="listBoxSettings"></param>
/// <param name="titleSettings"></param>
/// <param name="labelSettings"></param>
/// <param name="questionDefaultText"></param>
/// <param name="listBoxMargin"></param>
/// <param name="comboBoxBackground"></param>
/// <param name="comboBoxMaxLength"></param>
/// <param name="buttonBackgrounds"></param>
/// <param name="buttonBorders"></param>
/// <param name="buttonOnMouseOverColors"></param>
/// <param name="setQuestionBoxFocusType"></param>
/// <param name="secondsToDelay"></param>
/// <param name="OKClickAction"></param>
/// <param name="CANCELClickAction"></param>
/// <param name="COMMON_CLOSEClickAction"></param>
/// <returns></returns>
public static Border ShowListBoxDialog(Canvas canVas, string dialogGuid, double width, double internarlGridRowHeight, double listBoxRowHeight, double borderWidth, double borderHeight, double left, double top, Brush dialogBoxBorder, Thickness dialogBoxBorderThickness, Brush borderBackground, ListBoxSettings listBoxSettings, TitleSettings titleSettings, LabelSettings labelSettings, string defaultSelectedKey, Thickness listBoxMargin, Brush listBoxBackground, Brush buttonBackgrounds, Brush buttonBorders, Brush buttonOnMouseOverColors, bool applyDropShadow, Helpers.SetFocus setListBoxFocusType, int secondsToDelay, Action<ListBox> addItemsToCombo, Action<Object, SelectionChangedEventArgs> optionalSelectionChangedHandler, Action<string> OKClickAction, Action<string> CANCELClickAction, Action<string> COMMON_CLOSEClickAction)
        {
            Border bdr = ShowCustomFormDialog(canVas, dialogGuid, titleSettings.TitleCaption, width, internarlGridRowHeight, borderWidth, borderHeight, left, top, dialogBoxBorder, dialogBoxBorderThickness, borderBackground, titleSettings.TitleBackground, buttonBackgrounds, buttonBorders, buttonOnMouseOverColors, applyDropShadow,
                (sp, okButton, cancelButton, addContactLabel) =>
                {
                    Canvas innerCanvas = canVas;
                    addContactLabel.Height = titleSettings.TitleHeight;
                    addContactLabel.Margin = titleSettings.TitleMargin;
                    addContactLabel.Background = titleSettings.TitleBackground;
                    addContactLabel.Foreground = titleSettings.TitleForeground;
                    addContactLabel.SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Display);

                    //Font Settings 1 and 2                                                                                             
                    FasterWPF.FontExt.ApplyFontSettings(titleSettings.TitleFontSettings, addContactLabel);

                    //Grid Settings                                   
                    var glGr = new List<GridUnitType>();
                    glGr.Add(GridUnitType.Pixel);
                    var rlRh = new List<double>();
                    rlRh.Add(internarlGridRowHeight - 5);
                    var wlRh = new List<double>();
                    wlRh.Add(width - 10);

                    var newGridSettings = new FasterWPF.GridSettings();
                    newGridSettings.NumColumns = 1;
                    newGridSettings.NumRows = 1;
                    newGridSettings.ColUnitTypes = glGr;
                    newGridSettings.RowHeights = rlRh;
                    newGridSettings.RowUnitTypes = glGr;
                    newGridSettings.ColWidths = wlRh;
                    newGridSettings.Height = internarlGridRowHeight - 5;
                    newGridSettings.Width = borderWidth;

                    var rlRhLst = new List<double>();
                    rlRhLst.Add(listBoxRowHeight - 5);

                    var newGridSettingsLst = new FasterWPF.GridSettings();
                    newGridSettingsLst.NumColumns = 1;
                    newGridSettingsLst.NumRows = 1;
                    newGridSettingsLst.ColUnitTypes = glGr;
                    newGridSettingsLst.RowHeights = rlRhLst;
                    newGridSettingsLst.RowUnitTypes = glGr;
                    newGridSettingsLst.ColWidths = wlRh;
                    newGridSettingsLst.Height = listBoxSettings.Height - 5;
                    newGridSettingsLst.Width = borderWidth;
                    
                    labelSettings.LabelMinWidth = labelSettings.LabelMinWidth - 10;
                    labelSettings.LabelHeight = null; //restrict this for now . . .

                    var myListBox = sp.CreateLabelAndListBox(listBoxSettings, labelSettings, internarlGridRowHeight - 5, listBoxMargin, newGridSettings, newGridSettingsLst, listBoxBackground, 1, optionalSelectionChangedHandler);
                    addItemsToCombo(myListBox);

                    myListBox.SetSelectedContentControlColor( BrushExt.CreateColorFromString(listBoxSettings.HighlightBackgroundColor) );
                    myListBox.SetSelectedContentControlForeground( BrushExt.CreateSolidColorBrushFromString(listBoxSettings.HighlightForegroundColor) ); 

                    //Increase the height of the StackPanel and surrounding Border to make room for extra fields
                    sp.Height = 730.0;
                    (sp.GetBorderFromChildElement<StackPanel>() as Border).Height = 730.0;

                    Action<int> commonOKClickAction = o =>
                    {
                        Canvas secondCanvas = innerCanvas;
                        string selectedText = myListBox.SelectedContentControl().GetTextRuns<Grid, ListBox>().FirstOrDefault();

                        OKClickAction(selectedText.Trim());

                        //CLOSE DIALOG
                        if (FasterWPF.CommonExt.IsCompositeOnParent<Canvas>(secondCanvas, dialogGuid))
                        {
                            FasterWPF.Selectors.Select.DisposeEventsOnAllParents(sp);  //this will unsubscribe the SelectionChanged Event
                            FasterWPF.CommonExt.RemoveByKey<Canvas>(secondCanvas, dialogGuid);
                            COMMON_CLOSEClickAction(selectedText.Trim());
                        }
                    };
                    Action<Object, MouseButtonEventArgs> okClickHandlerMouse = ((Object o1, MouseButtonEventArgs ev1) =>
                    {
                        commonOKClickAction(0);
                    });

                    //Remove existing subscriptions for OK button and hook up new Click event             
                    FasterWPF.CommonExt.UnsubscribeMouseSingleClickOnBorderAll<Border>(okButton, true);
                    FasterWPF.CommonExt.SubscribeEventOnParent<FrameworkElement, MouseButtonEventArgs>(okButton, "PreviewMouseDown", okClickHandlerMouse);

                    //Remove existing subscriptions for CANCEL button and hook up new Click event 
                    Action<Object, MouseButtonEventArgs> mbehCancel = (o1, ev) =>
                    {
                        Canvas thirdCanvas = innerCanvas;
                        //CLOSE DIALOG
                        if (FasterWPF.CommonExt.IsCompositeOnParent<Canvas>(thirdCanvas, dialogGuid))
                        {
                            FasterWPF.Selectors.Select.DisposeEventsOnAllParents(sp);  //this will unsubscribe the SelectionChanged Event
                            FasterWPF.CommonExt.RemoveByKey<Canvas>(thirdCanvas, dialogGuid);

                            string selectedText = myListBox.SelectedContentControl().GetTextRuns<Grid, ListBox>().FirstOrDefault();
                            CANCELClickAction(selectedText.Trim());
                            COMMON_CLOSEClickAction(selectedText.Trim());
                        }
                    };
                    FasterWPF.CommonExt.UnsubscribeMouseSingleClickOnBorderAll<Border>(cancelButton, true);
                    FasterWPF.CommonExt.SubscribeEventOnParent<FrameworkElement, MouseButtonEventArgs>(cancelButton, "PreviewMouseDown", mbehCancel);

                    //Capture ESC and ENTER Key Input
                    Action<Object, KeyEventArgs> keyInputs = (o1, ev1) =>
                    {
                        Canvas fourCanvas = innerCanvas;

                        //CLOSE DIALOG
                        if (ev1.Key == Key.Escape && (FasterWPF.CommonExt.IsCompositeOnParent<Canvas>(fourCanvas, dialogGuid)))
                        {
                            FasterWPF.Selectors.Select.DisposeEventsOnAllParents(sp);  //this will unsubscribe the SelectionChanged Event
                            FasterWPF.CommonExt.RemoveByKey<Canvas>(fourCanvas, dialogGuid);

                            string selectedText = myListBox.SelectedContentControl().GetTextRuns<Grid, ListBox>().FirstOrDefault();
                            CANCELClickAction(selectedText.Trim());
                            COMMON_CLOSEClickAction(selectedText.Trim());
                        }
                        if (ev1.Key == Key.Enter)
                        {
                            commonOKClickAction(0);
                        }
                    };
                    FasterWPF.CommonExt.SubscribeEventOnParent<FrameworkElement, KeyEventArgs>(sp, "PreviewKeyDown", keyInputs);

                    if (defaultSelectedKey != null)
                    {
                        myListBox.SetSelectedKey(defaultSelectedKey);

                        //myComboBox.SetSelectedKey(cbGuid3);  if you need to set by GUID key, you could likely use this . . .
                    }
                }
            ); //end of ShowCustomFormDialog buildFormAction Function       

            //set focus to last field and then tab to first field
           if (bdr.IsThisElementAParent())
           {
                List<ListBox> ltBox = FasterWPF.Selectors.Select.SelectFrameworkElementsByType<ListBox>(bdr);
                if (ltBox != null && ltBox.Count > 0)
                {
                    var theTextBox = ltBox.Last();

                    if (setListBoxFocusType == Helpers.SetFocus.Delayed)
                    {
                        theTextBox.WaitForXSeconds(secondsToDelay, () =>
                        {
                            System.Windows.Forms.SendKeys.SendWait("{Tab}");
                            Keyboard.Focus(theTextBox);
                            theTextBox.Focus();
                        });
                    }

                    if (setListBoxFocusType == Helpers.SetFocus.Immediate)
                    {
                        System.Windows.Forms.SendKeys.SendWait("{Tab}");
                        Keyboard.Focus(theTextBox);
                        theTextBox.Focus();
                    }
                }
            }

return bdr;
}

Last edited Mar 15, 2014 at 9:28 PM by stagathome0069, version 33

Comments

No comments yet.