本文整理汇总了C#中System.Windows.Controls.ComboBox.ApplyTemplate方法的典型用法代码示例。如果您正苦于以下问题:C# ComboBox.ApplyTemplate方法的具体用法?C# ComboBox.ApplyTemplate怎么用?C# ComboBox.ApplyTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ComboBox
的用法示例。
在下文中一共展示了ComboBox.ApplyTemplate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetComboBoxPopup
private static Popup GetComboBoxPopup(ComboBox comboBox)
{
if (comboBox == null || comboBox.Template == null)
{
return null;
}
comboBox.ApplyTemplate();
return comboBox.Template.FindName(PopupTemplateName, comboBox) as Popup;
}
示例2: EnableEditing
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;
}
示例3: RemoveBeforeTemplateLoaded
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 ();
}
示例4: RemoveAfterTemplateLoaded_test
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 ();
}
示例5: EmitBeforeAndAfter2
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 ();
}
示例6: TemplateClosesDropdown
public void TemplateClosesDropdown ()
{
ComboBox box = new ComboBox ();
box.IsDropDownOpen = true;
Assert.IsTrue (box.ApplyTemplate (), "#1");
Assert.IsFalse (box.IsDropDownOpen, "#2");
}
示例7: SelectedItemUsesGenerator
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");
});
}