I'm trying to create a Window-derived class in XAML that can take a general argument, but I cannot describe a general argument in XAML so that it generates an incomplete class that matches my code file.
What I'm trying to do is replace all MessageBox calls to ask for custom questions, where I can give meaningful button headers ("Save and exit" / "Exit without saving" / "Do not leave", type item). I would like to be able to pass to the window a general argument, limited to System.Enum, which defines the return value for the selected parameter:
<Window x:Class="EvilPenguin.MultipleChoiceQuestionBox"> ...
public partial class MultipleChoiceQuestionBox<T> : Window where T : System.Enum { public MultipleChoiceQuestionBox() { InitializeComponent(); } public T SelectedOption { get; } }
- Is there a way to get my XAML to generate a partial class with the correct general argument?
- Am I doing it wrong? Is it a bad idea for some reason, or is there an easier way?
- Is this currently not possible in XAML? The x: TypeArgument attribute doesn't quite do what I want, but it assumes at least some aspects of XAML are aware of common arguments
Any help or tips are greatly appreciated.
generics c # wpf xaml
TheEvilPenguin
source share