Relativity
Relativity

Reputation: 6868

How to refer same namespace in XAML file?

This question is related to a WPF application.

I have a class as below in Project "Common". Namespace name is also same.

namespace Common
{
   public ViewBase : UserControl
   {
     // Code
   }
}

If I add a new abc.XAML file to same project (Common)...I would like to derive my code behind class(abc.xaml.cs file) from ViewBase class.

But in this case how do I write my header in XAML file ?

That is...how should refer my current namepace?

<Namespace:ViewBase x:Class=""
  xmlns:x=""
  ....>

Upvotes: 5

Views: 2309

Answers (1)

brunnerh
brunnerh

Reputation: 184376

You can declare the namespace using xmlns mapping, it is "active" in the current element as well, so the namespace can be used in the tag of the element declaring it. e.g.

<ns:ViewBase xmlns:ns="clr-namespace:Common" ...>

Upvotes: 7

Related Questions