gpt4 book ai didi

c# - 如何使用不同文件夹的本地/用户控制

转载 作者:太空狗 更新时间:2023-10-30 01:33:16 26 4
gpt4 key购买 nike

我有一个问题。

我不想重复我的代码,所以我看到我可以使用:用户控制/本地问题是当我使用本地时,我只能调用与这个文件在同一文件夹中的文件,而我想调用另一个文件夹中的文件。

示例:

在我的 Layout/_Menu.xaml 中

<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>

在我的 Store/Show.xaml 中

<Grid>
some code
</Grid>
<local:/Layout/_Menu /> <-- i Want something like this but its not work.

如果 _Menu.xaml 文件与 Show.xaml 位于同一文件夹(Store Folder),它将起作用。

你能帮帮我吗?谢谢。

最佳答案

我认为这与文件夹无关。在 XAML 中,大多数时候在引用当前类所在的命名空间时使用本地别名。这不是强制性的。

检查你要引用的类

<local:/Layout/_Menu /> 

位于您在 XAML 文件顶部声明的命名空间中。对于您的情况,检查 TeysserWP8.Views.misc 命名空间

xmlns:local="using:TeysserWP8.Views.misc"

关于c# - 如何使用不同文件夹的本地/用户控制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34417773/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com