本文整理汇总了C#中ComboBoxEntry.SizeRequest方法的典型用法代码示例。如果您正苦于以下问题:C# ComboBoxEntry.SizeRequest方法的具体用法?C# ComboBoxEntry.SizeRequest怎么用?C# ComboBoxEntry.SizeRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ComboBoxEntry
的用法示例。
在下文中一共展示了ComboBoxEntry.SizeRequest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public void Initialize (EditSession session)
{
this.session = session;
//if standard values are supported by the converter, then
//we list them in a combo
if (session.Property.Converter.GetStandardValuesSupported (session))
{
ListStore store = new ListStore (typeof (string));
ComboBoxEntry combo = new ComboBoxEntry (store, 0);
PackStart (combo, true, true, 0);
combo.Changed += TextChanged;
entry = combo.Entry;
entry.HeightRequest = combo.SizeRequest ().Height;
//but if the converter doesn't allow nonstandard values,
// then we make the entry uneditable
if (session.Property.Converter.GetStandardValuesExclusive (session)) {
entry.IsEditable = false;
entry.CanFocus = false;
}
//fill the list
foreach (object stdValue in session.Property.Converter.GetStandardValues (session)) {
store.AppendValues (session.Property.Converter.ConvertToString (session, stdValue));
}
//a value of "--" gets rendered as a --, if typeconverter marked with UsesDashesForSeparator
object[] atts = session.Property.Converter.GetType ()
.GetCustomAttributes (typeof (StandardValuesSeparatorAttribute), true);
if (atts.Length > 0) {
string separator = ((StandardValuesSeparatorAttribute)atts[0]).Separator;
combo.RowSeparatorFunc = delegate (TreeModel model, TreeIter iter) {
return separator == ((string) model.GetValue (iter, 0));
};
}
}
// no standard values, so just use an entry
else {
entry = new Entry ();
PackStart (entry, true, true, 0);
}
//either way we have an entry to play with
entry.HasFrame = false;
entry.Activated += TextChanged;
if (ShouldShowDialogButton ()) {
Button button = new Button ("...");
PackStart (button, false, false, 0);
button.Clicked += ButtonClicked;
}
Spacing = 3;
ShowAll ();
}