Show int property as hex?

Feb 22, 2011 at 4:50 PM

Just curious how you'd go about implementing the ability to specify that an int property should be shown as a hex value. I'm happy to do the work if you can give me your opinion on the best way to accomplish the task!

Feb 22, 2011 at 4:59 PM

it should be possible to use the FormatString attribute before your property:

public int HexNumber { get; set; }
But I think there is a bug in the PropertyEditor code since it doesn't use it. Let me know if you find the solution :)
Feb 22, 2011 at 5:02 PM

Thanks Objo.

I don't think that FormatString will work anyway - it won't let the user type "ABCDE" in the editor, for example. I was thinking we would need a valueConverter or typeConverter or something similar. Am I wrong here?

Feb 22, 2011 at 5:26 PM

You are right, and a converter should be able to solve this. I am not sure where it's best to handle this...

Is a converter attribute possible?


(I don't think the attribute can take an instance)

The Converter should be added as a property in the PropertyViewModel.

Then use the converter in the SetValue, GetValue in the PropertyViewModel?


If all ints should be edited as hex, then you can use a custom type editor. 

Feb 22, 2011 at 5:30 PM

Great, that's what I was thinking. I'll make an attempt at this and let you know the results.