private static Popup GetComboBoxPopup(ComboBox comboBox) { if (comboBox == null || comboBox.Template == null) { return null; } comboBox.ApplyTemplate(); return comboBox.Template.FindName(PopupTemplateName, comboBox) as Popup; }
private bool EnableEditing(ComboBox box) { //Включаем редактирование if (!box.IsEditable && box.SelectedItem != null && box.SelectedItem.ToString().Length == 0) { box.IsEditable = true; box.ToolTip = Languages.Translate("Enter - apply, Esc - cancel."); box.ApplyTemplate(); return true; } return false; }
public void RemoveBeforeTemplateLoaded () { int before = 0; int after = 0; ComboBox box = new ComboBox (); box.Loaded += delegate { before++; }; TestPanel.Children.Add (box); box.Loaded += delegate { after++; }; TestPanel.Children.Clear (); Enqueue (() => { Assert.AreEqual (1, before, "#1"); Assert.AreEqual (0, after, "#2"); }); Enqueue (() => { // Make sure that the second handler definitely hasn't being called Assert.AreEqual (1, before, "#3"); Assert.AreEqual (0, after, "#4"); // Apply the template and see if this causes Loaded emission Assert.IsTrue (box.ApplyTemplate (), "#5"); }); Enqueue (() => { Assert.AreEqual (1, before, "#6"); Assert.AreEqual (0, after, "#7"); }); EnqueueTestComplete (); }
public void RemoveAfterTemplateLoaded_test (bool match_tick_numbers) { int before = 0; int after = 0; ComboBox box = new ComboBox (); box.Loaded += delegate { before++; }; TestPanel.Children.Add (box); box.Loaded += delegate { after++; }; Enqueue (() => { Assert.AreEqual (1, before, "#1"); if (match_tick_numbers) { Assert.AreEqual (0, after, "#2"); } box.ApplyTemplate (); TestPanel.Children.Clear (); }); Enqueue (() => { Assert.AreEqual (1, before, "#3"); Assert.AreEqual (1, after, "#4"); }); Enqueue (() => { // Make sure that the values really aren't changing Assert.AreEqual (1, before, "#5"); Assert.AreEqual (1, after, "#6"); }); EnqueueTestComplete (); }
public void EmitBeforeAndAfter2 () { // If we call ApplyTemplate (), the second set of Loaded // events is emitted immediately. bool before_b = false; bool before_c = false; bool after_b = false; bool after_c = false; Canvas c = new Canvas (); ComboBox b = new ComboBox (); c.Children.Add (b); c.Loaded += delegate { before_c = true; }; b.Loaded += delegate { before_b = true; }; TestPanel.Children.Add (c); c.Loaded += delegate { after_c = true; }; b.Loaded += delegate { after_b = true; }; // Calling 'ApplyTemplate' emits the Loaded // events for the template, so all handlers will // be raised during the next tick. b.ApplyTemplate (); Enqueue (() => { Assert.IsTrue (before_b, "#1"); Assert.IsTrue (before_c, "#2"); Assert.IsTrue (after_b, "#3"); Assert.IsTrue (after_c, "#4"); }); EnqueueTestComplete (); }
public void TemplateClosesDropdown () { ComboBox box = new ComboBox (); box.IsDropDownOpen = true; Assert.IsTrue (box.ApplyTemplate (), "#1"); Assert.IsFalse (box.IsDropDownOpen, "#2"); }
public void SelectedItemUsesGenerator () { ComboBox box = new ComboBox (); CreateAsyncTest (box, () => { box.ApplyTemplate (); box.Items.Add (new object ()); box.SelectedIndex = 0; Assert.IsNotNull (box.ItemContainerGenerator.ContainerFromIndex (0), "#1"); }); }