Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Local / User Control with different folder

Tags:

c#

wpf

xaml

i have one question.

I don't want to duplicate my code so i see that i can use : User Control / Local The problem is when i use local, i can just only call the file who is in the same folder as this one, and i wanna call my file in another folder.

Example :

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

in my Store/Show.xaml

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

If the _Menu.xaml file was in the same folder than Show.xaml ( Store Folder ), its will work.

Can you help me ? Thanks.

like image 391
Tai Nguyen Avatar asked Dec 22 '15 14:12

Tai Nguyen


1 Answers

I do not think that this has something to do with folders. In XAML the local alias is used most of the time when referring to the namespace in which the current class exists. It is not something mandatory.

Check that the class you want to refer to

<local:/Layout/_Menu /> 

is in the namespase that you declared at the top of your XAML file. For your case, check in TeysserWP8.Views.misc namespace

xmlns:local="using:TeysserWP8.Views.misc"
like image 183
Athafoud Avatar answered Oct 06 '22 00:10

Athafoud