I want to create a templated control and, for my "shared" project, have used the Add New Item dialog to create a default templated control. This builds but, of course, it is not yet used in my project.
How do I reference it in my main page ? I see plenty of examples but none, that I can find, explain how to setup the namespaces.
It created ThemesGeneric.xaml and TitlebarTemplate.cs (the latter being the name I chose for my template).
Here's my Generic.xaml:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UnoTest.Shared">
<Style TargetType="local:TitlebarTemplate" >
...
</Style>
</ResourceDictionary>
And, here's a very condensed main page:
<Page
x:Class="UnoTest.ListPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UnoTest"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
...
</Grid.RowDefinitions>
... put template here ...
</Grid>
</Page>
What namespace to I need to add to reference the template ? And, please include the syntax for actually referencing it.
I'm doing this for the Uno platform, but I think the syntax is the same as for UWP.
EDIT
I put this in my page:
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Themes/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
But I still can't find a way to reference TitlebarTemplate
.
question from:
https://stackoverflow.com/questions/65924336/uwp-how-to-setup-namespace-for-templated-control 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…