WPF XAML Global Reference

Is there a way to reuse a third-party control link?

For example, I have a link to my App.xaml

xmlns:cust="clr-namespace:ThirdParty.Controls;assembly=ThirdParty.Controls"

I don't want to repeat this namespace of an xml-sided control on every page / control that needs a library control.

Do I need to centralize these links and use the prefix defined here? Also of concern is the possibility of each control having a different prefix. In asp.net, you would specify the link in web.config, and it was available worldwide, I just want to see if there is a similar method in WPF.

+3
source share
2 answers

Two options that I think of

1) UserControl, UserControl .

2) -, DynamicResource .

.

, ContentControl, .

<ContentControl Template="{DynamicResource thirdPartyControlTemplate}" />

ControlTemplate App.Xaml, .

  xmlns:thridParty="clr-namespace:WpfCustomControlLibrary1;assembly=WpfCustomControlLibrary1"                >
<Application.Resources>
    <ControlTemplate x:Key="thirdPartyControlTemplate" TargetType="{x:Type ContentControl}">
        <thridParty:ThirdPartyControl />
    </ControlTemplate>
</Application.Resources>

, ,

+1

:

<ControlTemplate TargetType="Label" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:s="clr-namespace:System;assembly=mscorlib" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

- .

0
source

All Articles