I'm new to C#/Windows store apps development and I have a problem: I'm getting
The name "CustomTemplate1" does not exist in the namespace "using:QSTLibrary.WIN8"
I work on a project which has 2 libraries (one portable(without any GUI) and one platform specific(Win store apps)) and a startup project which is based on these 2 libs.
On the platform-specific library I want to add a templated control
, but when adding it using the add -> new item -> templated control
the Generic.xaml from the auto-generated "Themes" folder has the above error.
Here is Generic.xaml:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:QSTLibrary.WIN8">
<Style TargetType="local:CustomTemplate1"> //HERE IS THE PROBLEM !!!!
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:CustomTemplate1">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
Here is CustomTemplate1:
using System;
using System.Collections.Generic;
using System.Linq;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Documents;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
// The Templated Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234235
namespace QSTLibrary.WIN8
{
public sealed class CustomTemplate1 : Control
{
public CustomTemplate1()
{
this.DefaultStyleKey = typeof(CustomTemplate1);
}
}
}
QSTLibrary.WIN8 is the platform-specific library
Please help me with this issue.
I've solve it by copying the content of the Generic.xaml, delete the Generic.xaml, build, add again a new xaml file under Themes folder (name it Generic.xaml) and paste the initial content of the Generic.xaml. build again and works. My conclusion is that I must first compile the lib containing the CustomTemplate1.cs and after this compile, the lib will be able to add references to the CustomTemplate1.cs. Because of the initial error, the lib didn't compiled, so removing the file with the error, compiling, adding again the xaml was my way to solve this issue. Looks like a Visual Studio bug for me.