C# 如何对不同的文件夹使用本地/用户控件
我有一个问题 我不想复制我的代码,这样我就可以使用:User Control/Local 问题是当我使用local时,我只能调用与此文件夹相同的文件,我想调用另一个文件夹中的文件 例如: 在我的布局中/_Menu.xamlC# 如何对不同的文件夹使用本地/用户控件,c#,wpf,xaml,C#,Wpf,Xaml,我有一个问题 我不想复制我的代码,这样我就可以使用:User Control/Local 问题是当我使用local时,我只能调用与此文件夹相同的文件,我想调用另一个文件夹中的文件 例如: 在我的布局中/_Menu.xaml <UserControl x:Class="TeysserWP8.Views.misc._menuLayout" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<UserControl
x:Class="TeysserWP8.Views.misc._menuLayout"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TeysserWP8.Views.misc"
xmlns:drawerLayout="using:DrawerLayout"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="#FF563AA0" Offset="1"/>
</LinearGradientBrush>
</Grid.Background>
<Button Command="{Binding MyDietViewCommand}" Content="Mes Régimes" Margin="10,21,0,502" Width="245"></Button>
<Button Command="{Binding DietStoreViewCommand}" Content="Régimes Store" Margin="10,89,0,434" Width="245"></Button>
<Button Command="{Binding LogoutViewCommand}" Content="Déconnexion" Margin="10,502,0,21" Width="245"></Button>
</Grid>
</UserControl>
在my Store/Show.xaml中
<Grid>
some code
</Grid>
<local:/Layout/_Menu /> <-- i Want something like this but its not work.
一些代码
我不认为这与文件夹有关。在XAML中,当引用当前类所在的命名空间时,大部分时间都使用本地别名。这不是强制性的
检查您要引用的类
<local:/Layout/_Menu />
只需为要使用的控件所在的命名空间添加命名空间映射,类似于xmlns:local=“using:TeysserWP8.Views.misc”
行。看,是的,你说得对,谢谢,谢谢。在添加了想要的名称空间后,它对我起了作用:xmlns:local=“using:TeysserWP8.Views.misc”
。
xmlns:local="using:TeysserWP8.Views.misc"