Have you ever tried to create a DataTemplate for a Generic Class? During last week I had to battle this issue and it is allot more complicated then it sounds. As far as I can tell Creating DataTemplates for Generic classes is impossible. There is some kind of workaround but it is not all that good. OK lets get down to business. This is the class we are trying to template
1: public class GenericClass<T>
2: {
3: private T m_Val;
4:
5: public T Val
6: {
7: get { return m_Val; }
8: set { m_Val = value; }
9: }
10: }
Continue Reading...
Sometimes we are using the same patterns of code over and over again. Those of us who are lazy (but smart) will create their own code snippets, if you are not familiar with this subject, read about how to create code snippets easily. But what if we need to create lots of classes with the same pattern? Code snippets may not be enough because they lack of some functionality which is needed to achieve our goal. Consider the following code:
abstract class FourWheelsVehicle : IVehicle
{
abstract public double MaxVelocity { get; }
abstract public string Manufacturer { get; }
abstract public double Price { get; }
abstract public int YearManufactured { get; }
virtual public int NumberOfWheels
{
get { return 4; }
}
}
An abstract class called FourWheelsVehicle implements the IVehicle interface (which is not presented here because it is not important for our matter). Our task is to create classes which represent each and every existing 4 wheels vehicle, there is a lot of work to do, a huge amount of work. So, I started by implementing Mazda6 class:
Continue Reading...
This is a good one!
Every one knows that when you add a new class to a project it is private by default, but still when you compile for the first time, the compilation fails and only then you remember to add the “public” before the class name. Tired of this? Here’s what you do in [...]
Continue Reading...