Well i have a control that inherits usercontrol(view) and im using it as you use a usercontrol (a base control) now here is the problem if i do
MessageBox.Show(this.GetType().ToString());
i get different messages in runtime and design time, in design time i get View and i runtime i get the class name of the xaml file inheriting the view...
How can i get the inheriting class type in design time instead of the base class?
Here comes some code:
First we have the view Class
public class View : UserControl
{
public override void OnApplyTemplate()
{
MessageBox.Show(this.GetType().ToString());
base.OnApplyTemplate();
}
}
Then we have a XAML file:
<local:View x:Class="WpfApplication2.Test"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WpfApplication2"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
</Grid>
</local:View>
now if you compile and open "WpfApplication2.Test" in VisualStudio 2010 you will get a message box that says "WpfApplication2.View"..
But if you place the Test control in your MainWindow and press Run(F5) you get WpfApplication2.Test.. what i want is to have the same response in design time that i have in run time...