2011-06-25 13 views
1

私は自分で作成したタイプの設定を定義しようとしていますが、設定UIのタイプのコンボボックスで自分のクラスを見つけることができませんComboBoxで「ブラウズ」を選択して起動した「ブラウズ」フォーム)。C#の設定をカスタマイズされたクラスで使用する

カスタムクラスを設定内で使用するにはどうすればよいですか?

私のクラス:

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(); 
     } 
    } 
} 

答えて

2

は、それが唯一のバイナリシリアライズを定義したりTHIS質問/答えを読んでIXmlSerializableの代わりSerializableを使用してみてください。

+0

属性はありません。しかし、同じ名前のインタフェースは存在します。私は両方のインターフェイスを実装し、[Serializable]属性を添付する必要がありますか? –

+0

@ギラード:私の編集のリンクを見てください、私は間違っているかもしれません... – ChrFin

+0

ありがとうございます:) –

関連する問題