wpf-rule-view-viewmodel-wiring-communitytoolkit — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited wpf-rule-view-viewmodel-wiring-communitytoolkit (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
<!-- ============================================================================= AI Agent Reading Hint — wpf-dev-pack Composition Style Anchor =============================================================================
CANONICAL DEFINITIONS (per docs/TERMINOLOGY.md):
(Microsoft Learn: navigation/composition identifier = ViewModel type)
<DataTemplate DataType="{x:Type vm:XxxViewModel}"> <view:XxxView /> </DataTemplate>
PROHIBITED (per prohibitions.md):
NOTE FOR AI AGENTS: Earlier plugin docs (≤ v1.5.x / v1.6.4) labeled this file's pattern as "View First MVVM". That label was technically incorrect per Microsoft's definition (the lookup key here is the ViewModel type → ViewModel First) and was corrected in v1.6.4. The actual code rules are unchanged. Use v1.6.4+ terminology in generated code and comments. ============================================================================= -->
Applies when CommunityToolkit.Mvvm is the active MVVM framework.
Composition style: ViewModel First Composition + Stateful ViewModel (Mappings.xaml + implicit DataTemplate). See docs/TERMINOLOGY.md.DataTemplate must be defined without `x:Key` — only DataType — for automatic type matching.Mappings.xaml must be merged into Application.Resources.ContentControl.Content.DataContext — no separate wiring needed.<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:MyApp.ViewModels;assembly=MyApp.ViewModels"
xmlns:views="clr-namespace:MyApp.Views">
<DataTemplate DataType="{x:Type vm:HomeViewModel}">
<views:HomeView />
</DataTemplate>
<DataTemplate DataType="{x:Type vm:SettingsViewModel}">
<views:SettingsView />
</DataTemplate>
</ResourceDictionary><Application x:Class="MyApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Mappings.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>namespace MyApp.ViewModels;
public sealed partial class MainWindowViewModel : ObservableObject
{
[ObservableProperty] private object? _currentViewModel;
public MainWindowViewModel()
{
CurrentViewModel = new HomeViewModel();
}
[RelayCommand]
private void NavigateToHome()
{
CurrentViewModel = new HomeViewModel();
}
[RelayCommand]
private void NavigateToSettings()
{
CurrentViewModel = new SettingsViewModel();
}
}<Window x:Class="MyApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="10">
<Button Content="Home" Command="{Binding NavigateToHomeCommand}" Margin="5" />
<Button Content="Settings" Command="{Binding NavigateToSettingsCommand}" Margin="5" />
</StackPanel>
<!-- ViewModel bound to Content → DataTemplate auto-renders the View -->
<ContentControl Grid.Row="1" Content="{Binding CurrentViewModel}" />
</Grid>
</Window>namespace MyApp;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
DataContext = new MainWindowViewModel();
}
}Views are UserControls. Use d:DataContext for design-time support.
<UserControl x:Class="MyApp.Views.HomeView"
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:vm="clr-namespace:MyApp.ViewModels;assembly=MyApp.ViewModels"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=vm:HomeViewModel}">
<Grid>
<TextBlock Text="{Binding WelcomeMessage}" FontSize="24"
HorizontalAlignment="Center" VerticalAlignment="Center" />
</Grid>
</UserControl>For recursive data (folder trees, org charts), use HierarchicalDataTemplate:
<HierarchicalDataTemplate DataType="{x:Type vm:FolderViewModel}"
ItemsSource="{Binding Children}">
<StackPanel Orientation="Horizontal">
<Image Source="/Icons/folder.png" Width="16" Height="16" Margin="0,0,5,0" />
<TextBlock Text="{Binding Name}" VerticalAlignment="Center" />
</StackPanel>
</HierarchicalDataTemplate>
<!-- Leaf nodes use plain DataTemplate -->
<DataTemplate DataType="{x:Type vm:FileViewModel}">
<StackPanel Orientation="Horizontal">
<Image Source="/Icons/file.png" Width="16" Height="16" />
<TextBlock Text="{Binding FileName}" Margin="5,0" />
</StackPanel>
</DataTemplate>| DataTemplate | HierarchicalDataTemplate |
|---|---|
| Flat data | Hierarchical/nested data |
| No children | Has ItemsSource for children |
ContentControl | TreeView, Menu, MenuItem |
MyApp.WpfApp/
├── Views/
│ ├── HomeView.xaml
│ ├── HomeView.xaml.cs
│ ├── SettingsView.xaml
│ └── SettingsView.xaml.cs
├── App.xaml
├── App.xaml.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
└── Mappings.xaml ← DataTemplate definitions
MyApp.ViewModels/
├── MainWindowViewModel.cs
├── HomeViewModel.cs
└── SettingsViewModel.cs~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.