locked
[UWP]The name "(class name)" does not exist in the namespace RRS feed

  • Question

  • I am working on a simple UWP project using data template binding in VS 2015. When ever I try to specify the type for the Datatemplate I get an error.

    XAML:

     <SplitView x:Name="MySplitView" Grid.Row="1" DisplayMode="CompactOverlay" Background="LightGray" OpenPaneLength="200"  >
                <SplitView.Pane>
                    <ListView x:Name="MyListview" ItemsSource="{x:Bind NavigationItems}"  >
                        <ListView.ItemTemplate>
                            <DataTemplate x:DataType="local:NavItem" >
                                <StackPanel Orientation="Horizontal">
                                    <RelativePanel>
                                        <Button x:Name="Icon"  FontFamily="Segoe MDL2 Assets" Content="{x:Bind ButtonIcon}" Width="50" Height="50"/>
                                        <TextBlock x:Name="Section" Text="{x:Bind SectionTitle}" RelativePanel.RightOf="Icon" />
                                    </RelativePanel>
                                </StackPanel>
                            </DataTemplate>
                        </ListView.ItemTemplate>

    This is the class

    namespace Adaptive_News_Layout
    {
        public class NavItem
        {
            public string ButtonIcon { get; set; }
            public string SectionTitle { get; set; }
        }
    }
    The error reads: The name "NavItem" does not exist in the namespace "using:Adaptive_News_Layout"


    Learning to make Windows Apps


    Tuesday, July 5, 2016 1:23 AM

Answers

  • You should be able to compile the application provided that you have declared the namespace in your XAML markup like this:

    <Page .... xmlns:local="using:Adaptive_News_Layout" ... />

    Try to build the application. If you still cannot get it to work, then please upload a reproducible sample of your issue to OneDrive and post the link to it here for further help.

    Hope that helps.

    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

    • Proposed as answer by Barry Wang Friday, July 8, 2016 9:22 AM
    • Marked as answer by Barry Wang Wednesday, July 13, 2016 10:10 AM
    Wednesday, July 6, 2016 4:37 PM

All replies

  • Hi williab3,

    Since this issue is related to the UWP, I help yo move this case to the Developing Universal Windows apps forum for dedicated support.

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, July 6, 2016 5:29 AM
  • You should be able to compile the application provided that you have declared the namespace in your XAML markup like this:

    <Page .... xmlns:local="using:Adaptive_News_Layout" ... />

    Try to build the application. If you still cannot get it to work, then please upload a reproducible sample of your issue to OneDrive and post the link to it here for further help.

    Hope that helps.

    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

    • Proposed as answer by Barry Wang Friday, July 8, 2016 9:22 AM
    • Marked as answer by Barry Wang Wednesday, July 13, 2016 10:10 AM
    Wednesday, July 6, 2016 4:37 PM