1

I'm trying to define a setting w/ a type made by me'self, but I can't seem to find my class in the ComboBox of types in the settings UI (nor in the "Browse" form launched by choosing 'browse' in the ComboBox).

How can I use custom classes inside settings?

My class:

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();
        }
    }
}
Gilad Naaman
  • 6,390
  • 15
  • 52
  • 82

1 Answers1

2

Try to use IXmlSerializable instead of Serializable as it only defines binary serializability or read THIS question/answers.

Community
  • 1
  • 1
Christoph Fink
  • 22,727
  • 9
  • 68
  • 113
  • No attribute. Interface in the same name, though, does exist. Should I both implement the interface and attach the [Serializable] Attribute? – Gilad Naaman Jun 25 '11 at 11:46