Click here to Skip to main content
15,899,549 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to create a custom control, in that custom control I want to give option to bind uint, int and float data type as a property and want to set the property in xaml.How can I proceed that?
Please give the way.

What I have tried:

public static readonly DependencyProperty CustDatatypeProperty =
DependencyProperty.Register("DataTypeValue", typeof(whatshoulIgiveHere), typeof(RangeControl), new UIPropertyMetadata(null));

   public whatType DataTypeValue
   {
       get { return (whatType )GetValue(CustDatatypeProperty ); }
       set { SetValue(CustDatatypeProperty , value); }
   }
Posted
Comments
LLLLGGGG 18-Jul-17 9:50am    
uint, int and float can all be casted implicitly to double... So if you don't need to use large integer values, use double and you'll be fine...
atigyo 18-Jul-17 10:22am    
Thanks.this can be done but what if I want to give other datatypes?I am curious about this.
LLLLGGGG 18-Jul-17 13:20pm    
You could write a simple class like
public class MysteriousType{object o;Type t;} 
and then cast o to the type t... it works, but it's a horrible solution.The best would be writing classes in hierarchy using inheritance and pass an instance of a base class. Then with the is operator you can handle the rest.
atigyo 19-Jul-17 1:18am    
thank you,I am going to try that.Could you be more specific about it?
atigyo 20-Jul-17 3:24am    
thank you,
Same thing I attended.after that I created Enumeration of datatypes and did TryParse to get desired output.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900