Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 是否可以创建共享的xaml命名空间?_Wpf_Xaml - Fatal编程技术网

Wpf 是否可以创建共享的xaml命名空间?

Wpf 是否可以创建共享的xaml命名空间?,wpf,xaml,Wpf,Xaml,期待一个相当简单的是/否/你为什么要这么做,你这个白痴回答 我的绝大多数文件都有完全相同的名称空间声明 <UserControl x:Class="myNamespace.Views.PageView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml

期待一个相当简单的是/否/你为什么要这么做,你这个白痴回答

我的绝大多数文件都有完全相同的名称空间声明

<UserControl x:Class="myNamespace.Views.PageView"
             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:mvvm="http://prismlibrary.com/"
             xmlns:controls="clr-namespace:MyNamespace.Controls.Views;assembly=MyNamespace.Controls"
             mvvm:ViewModelLocator.AutoWireViewModel="true"
             AutomationProperties.AutomationId="{Binding PageName}"
             mc:Ignorable="d"
             HorizontalAlignment="Stretch"
             VerticalAlignment="Stretch"
             d:DesignHeight="618"
             d:DesignWidth="1024" >

将这些名称空间添加到不同的页面,autocomplete有时会给它们不同的名称。控件可能会被称为视图,mvvm可能会被更改为prism等

有没有办法在某个地方声明一组默认名称空间,然后将该引用添加到usercontrol?即

<UserControl x:Class="myNamespace.Views.PageView"
    something="{DynamicResource DefaultControlSetup}">


我知道这样做可能没有什么意义,但这是我脑子里想的东西,我至少想知道这是否可能,即使它毫无意义。

不,你不能使用某种
动态资源
或其他标记扩展来导入名称空间


这些需要在每个XAML文件中定义,就像您必须使用指令向每个C#源代码文件添加适当的

认为情况就是这样。谢谢你的快速回答。