Search code examples
xamldata-bindingwin-universal-appsplitview

Data Binding in splitview error


I'm trying to use a SplitView whose Buttons come from data binding. Here is the code:

<SplitView Name="AnnouncementSplitView" 
           DisplayMode="CompactInline" 
           OpenPaneLength="200" 
           CompactPaneLength="56" 
           HorizontalAlignment="Left" Grid.Row="1">
        <ListView ItemsSource="{x:Bind Parts}" 
                  SelectionMode="Single" 
                  Name="CongregationList" 
                  SelectionChanged="LoadAnnouncements">
            <ListView.ItemTemplate>
                <DataTemplate x:DataType="data:Part">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Name="PartImage" 
                                   Text="&#xE125;" 
                                   FontFamily="Segoe MDL2 Assets"/>
                        <TextBlock Name="PartName" 
                                   Text="{x:Bind PartName}" 
                                   Margin="20,0,0,0"/>
                    </StackPanel>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </SplitView>

I get an error at the following line:

x:DataType="data:Part"

that the class Part does not exist in the namespace defind by data although it does..


Solution

  • The mistake was that that I had created the class after I wrote the code in XAML. So when it was written the compiler tried to find a nonexisting class. All I had to do is rewrite the XAML code, clean and rebuild the solution...