【发布时间】:2011-09-22 13:49:17
【问题描述】:
我正在尝试使用我自己制作的类型定义设置,但我似乎无法在设置 UI 的类型组合框中找到我的类(也无法在由在 ComboBox 中选择“浏览”)。
如何在设置中使用自定义类?
我的班级:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using Key = System.Windows.Input.Key;
namespace GameOfLife
{
[Serializable()]
class KeyShortCut
{
[XmlElement("Key")]
public Key Key { get; private set; }
[XmlAttribute("Ctrl")]
public bool Ctrl { get; private set; }
[XmlAttribute("Alt")]
public bool Alt { get; private set; }
[XmlAttribute("Shift")]
public bool Shift { get; private set; }
public KeyShortCut(Key Key, bool Ctrl = false, bool Alt = false, bool Shift = false)
{
this.Key = Key;
this.Ctrl = Ctrl;
this.Alt = Alt;
this.Shift = Shift;
}
public override string ToString()
{
StringBuilder str = new StringBuilder(this.Key.ToString());
if (Ctrl)
str.Insert(0, "Ctrl + ");
if (Alt)
str.Insert(0, "Alt + ");
if (Shift)
str.Insert(0, "Shift + ");
return str.ToString();
}
}
}
【问题讨论】: