XAML - How to add new property to a Button?

Tom Knowlton
Tom Knowlton used Ask the Experts™
on
In XAML / C# - is it possible to add a custom attribute or property to a <Button/> that is an enumeration?

 
     <Button x:Name="acButton"
                Content="/"
                Margin="5"
                Grid.Row="1"

[b]Kind="Division"[/b]


                Grid.Column="0"/>

Open in new window


"Kind" would give intellisense (code completion) options of "Addition, Subtraction, Multiplication, Division"

In the C# code behind, something like this:

  public enum SelectedOperator
    {
        Addition,
        Subtraction,
        Multiplication,
        Division
    }

Open in new window




How do you code it?  Do you inherit from Button?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
You can use attached properties to stabdart controls.
Look this article for more information:
https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/attached-properties-overview
Tom KnowltonWeb developer

Author

Commented:
I read the article, but I don't get it.

Can you give me a simple example?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial