wpfxamlbinding

Is there a simple way to specify int value in xaml


I want set Tag property with int value in xaml. But defining int in resources and then reference this resource as binding looks not a perfect way for me. It is easier just to convert string value to int from code. So, is there some way to easy set int value in xaml?


Solution

  • If not interested in declaring it as resource, you can declare it in-line somewhat like this:

        <Button>
            <Button.Tag>
                <sys:Int32>5</sys:Int32>
            </Button.Tag>
        </Button>