簡體   English   中英

如何使用不同文件夾的本地/用戶控制

[英]How to use Local / User Control with different folder

我有一個問題。

我不想復制我的代碼所以我看到我可以使用:用戶控制/本地問題是當我使用本地時,我只能調用與此文件夾在同一文件夾中的文件,我想打電話我的文件在另一個文件夾中

示例:

在我的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(存儲文件夾)位於同一文件夾中,則它將起作用。

你能幫助我嗎 ? 謝謝。

我不認為這與文件夾有關。 在XAML中,當引用當前類所在的命名空間時,大多數時候都使用本地別名。 這不是強制性的。

檢查您要引用的類

<local:/Layout/_Menu /> 

位於您在XAML文件頂部聲明的namespase中。 對於您的情況,請檢查TeysserWP8.Views.misc命名空間

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM