/// <summary> /// Tries to get the selected item in a combobox /// </summary> /// <typeparam name="TEnum">The Type of the enumeration which holds the items of the combobox</typeparam> /// <param name="this">The combobox</param> /// <param name="item">ot parameter for the selected item</param> /// <returns>true if there was a selection, false otherwise</returns> public static bool TryGetSelectedEnumItem <TEnum>(this ComboBox @this, out TEnum item) where TEnum : struct, IConvertible { var success = @this.TryGetSelectedItem(out Tuple <object, string> enumValue); item = success ? (TEnum)enumValue.Item1 : default(TEnum); return(success); }