Repository navigation
Description
Current behavior
I have a page with two DataTemplates.
However, I get the following error message:
D:..\HtSuiteUno.Wasm\Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator\MainShellView_627ecb4bb5e786243ce503652800ca11.cs(371,5,371,35): error CS0103: Der Name "NavigationViewItemDataTemplate" ist im aktuellen Kontext nicht vorhanden.
D:..\HtSuiteUno.Wasm\Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator\MainShellView_627ecb4bb5e786243ce503652800ca11.cs(372,5,372,42): error CS0103: Der Name "NavigationViewItemProfileDataTemplate" ist im aktuellen Kontext nicht vorhanden.
If I start the project as an UWP app, I don't get any errors and everything works as expected.
<Page
x:Class="HtSuiteUno.Views.Shell.MainShellView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewManagement="using:Windows.UI.ViewManagement"
xmlns:clock="using:HtSuiteUno.UserControls.Clock"
xmlns:shell="using:HtSuiteUno.ViewModels.Shell"
xmlns:common="using:HtSuiteUno.Infrastructure.Common"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
<DataTemplate x:Name="NavigationViewItemDataTemplate" x:DataType="shell:NavigationItem">
<Grid Height="40">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="32" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<FontIcon Glyph="{x:Bind Glyph}"
HorizontalAlignment="Left"
FontSize="16" />
<TextBlock Grid.Column="1"
Text="{x:Bind Label}"
VerticalAlignment="Center" />
<TextBlock Grid.Column="2"
VerticalAlignment="Center"
Margin="12,0"
Text="{x:Bind Badge, Mode=OneWay}"
Foreground="{StaticResource Error}" />
</Grid>
</DataTemplate>
<DataTemplate x:Name="NavigationViewItemProfileDataTemplate" x:DataType="common:UserInfo">
<Grid Width="300" Height="40">
<Grid IsTapEnabled="False">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="32" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="4" />
</Grid.ColumnDefinitions>
<Viewbox Margin="-2,9,0,9" HorizontalAlignment="Left">
<PersonPicture ProfilePicture="{x:Bind PictureSource, Converter={StaticResource ObjectToImageConverter}}"
DisplayName="{x:Bind DisplayName}" />
</Viewbox>
<TextBlock Grid.Column="1" Text="{x:Bind DisplayName}" VerticalAlignment="Center" />
</Grid>
<Button Margin="-4,0,0,0" BorderThickness="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
Opacity="0" Click="OnLogoff" />
</Grid>
</DataTemplate>
</Page.Resources>
<Grid>
<NavigationView
x:Name="navigationView"
Grid.Row="1"
Style="{StaticResource BackButtonNavigationViewStyle}"
Background="#EBEBEB"
MenuItemsSource="{x:Bind ViewModel.Items}"
MenuItemTemplate="{StaticResource NavigationViewItemDataTemplate}"
SelectedItem="{x:Bind ViewModel.SelectedItem, Mode=TwoWay}"
SelectionChanged="OnSelectionChanged"
IsPaneOpen="{x:Bind ViewModel.IsPaneOpen, Mode=TwoWay}"
AlwaysShowHeader="False"
IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
<Grid>
<Frame x:Name="frame">
<Frame.ContentTransitions>
<TransitionCollection>
<NavigationThemeTransition />
</TransitionCollection>
</Frame.ContentTransitions>
</Frame>
</Grid>
<NavigationView.PaneFooter>
<NavigationViewItem ContentTemplate="{StaticResource NavigationViewItemProfileDataTemplate}"
Content="{x:Bind ViewModel.UserInfo, Mode=OneWay}" />
</NavigationView.PaneFooter>
</NavigationView>
</Grid>
</Page>Expected behavior
No response
How to reproduce it (as minimally and precisely as possible)
No response
Workaround
No response
Works on UWP/WinUI
Yes
Environment
Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia
NuGet package version(s)
No response
Affected platforms
WebAssembly, Windows
IDE
Visual Studio 2019
IDE version
16.11.3
Relevant plugins
No response
Anything else we need to know?
No response
Activity
Youssef1313 commentedon Oct 5, 2021
Simpler repro:
The generated code for that:
The actual bug here is that we don't generate a backing field for
MyDataTemplate. This may get fixed with #7108, but can't say for sure without testing.jeromelaban commentedon Oct 6, 2021
Thanks @Youssef1313 for the validation. @dojo90 you may work around the issue by using
x:Keyinstead ofx:Name(unless you actually need to use thex:Namefrom the code behind).[-]error CS0117: "NavigationViewItem" does not contain a definition for "UpdateResourceBindings".[/-][+]error CS0117: `NavigationViewItem` does not contain a definition for `UpdateResourceBindings`[/+]NavigationView#21054github-actions commentedon Aug 1, 2025
Hey there — just a heads-up that this issue has been quiet for over a year. If there’s no update or comment in the next 10 days, it’ll be closed automatically. Feel free to remove the stale label or drop a note to keep it open.
MartinZikmund commentedon Aug 1, 2025
Still relevant
MartinZikmund commentedon Apr 8, 2026
Repro generator
This issue was classified as not reproducible with a code sample or test.
Reason: Code generation bug — NavigationViewItem missing UpdateResourceBindings definition.