Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF get Type in Design time?
    text
    copied!<p>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 </p> <pre><code>MessageBox.Show(this.GetType().ToString()); </code></pre> <p>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...</p> <p>How can i get the inheriting class type in design time instead of the base class?</p> <p>Here comes some code:</p> <p>First we have the view Class</p> <pre><code>public class View : UserControl { public override void OnApplyTemplate() { MessageBox.Show(this.GetType().ToString()); base.OnApplyTemplate(); } } </code></pre> <p>Then we have a XAML file:</p> <pre><code>&lt;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"&gt; &lt;Grid&gt; &lt;/Grid&gt; &lt;/local:View&gt; </code></pre> <p>now if you compile and open "WpfApplication2.Test" in VisualStudio 2010 you will get a message box that says "WpfApplication2.View"..</p> <p>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...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload