Skip to content

fix(wpf): ship a default theme in ReactiveUI.WPF.Reactive so ViewModelViewHost renders#4412

Draft
glennawatson wants to merge 1 commit into
mainfrom
fix/wpf-reactive-viewmodelviewhost-theme
Draft

fix(wpf): ship a default theme in ReactiveUI.WPF.Reactive so ViewModelViewHost renders#4412
glennawatson wants to merge 1 commit into
mainfrom
fix/wpf-reactive-viewmodelviewhost-theme

Conversation

@glennawatson

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Bug fix.

What is the new behavior?

ViewModelViewHost (and its base TransitioningContentControl) now resolve their default control template when used from the ReactiveUI.WPF.Reactive package, so the resolved view is inserted into the visual tree and the content is displayed.

The single ~40 KB TransitioningContentControl template is authored once, in a shared theme dictionary (ReactiveUI.Wpf.Shared/Themes/TransitioningContentControlTemplate.xaml) that targets the built-in ContentControl and therefore names no assembly-specific type. Each WPF assembly ships a small Themes/Generic.xaml that merges the shared template and binds it to that assembly's own TransitioningContentControl through a bare clr-namespace. As a result both ReactiveUI.WPF and ReactiveUI.WPF.Reactive pack their own themes/generic.xaml theme dictionary from a single source template.

What is the current behavior?

TransitioningContentControl sets DefaultStyleKey = typeof(TransitioningContentControl) and the assembly declares ThemeInfo(SourceAssembly), so WPF looks for the default template in each assembly's own themes/generic.xaml. The lean ReactiveUI.WPF assembly packed one and worked, but ReactiveUI.WPF.Reactive shipped no XAML at all - so its themes/generic.xaml was missing, the default template was never found, and ViewModelViewHost rendered nothing (blank window). Manually merging the lean package's theme dictionary worked around it.

Closes #4394

What might this PR break?

None expected. No public API changes. The lean ReactiveUI.WPF theme is sourced from the same shared template and continues to resolve as before.

Checklist

  • I have read the Contribute guide
  • Tests have been added or updated (for bug fixes / features)
  • Docs have been added or updated (for bug fixes / features)
  • Changes target the main branch
  • PR title follows Conventional Commits

Additional information

Root cause note: a XAML xmlns mapped to http://reactiveui.net cannot resolve a control type defined in the same assembly being compiled - the markup compiler resolves URI namespaces against referenced assemblies only, while a bare clr-namespace is what defers local-type resolution to the second markup pass. That is why one physical Generic.xaml using the URI namespace fails to compile in the defining assembly, and why the template body (shared, type-free) is split from the tiny per-assembly type binding.

Verified by building both WPF assemblies (clean, correct themes/generic.baml + themes/transitioningcontentcontroltemplate.baml resource paths) and running the theme-template resolution tests plus the existing ViewModelViewHost / TransitioningContentControl tests against both the lean and .Reactive assemblies (via the net8.0-windows TFM under Wine). CI on windows-latest is authoritative.

…lViewHost renders

- Extract the TransitioningContentControl control template into a single shared theme
  dictionary (ReactiveUI.Wpf.Shared/Themes) that targets the built-in ContentControl, so it
  carries no assembly-specific type and one copy packs into both WPF assemblies.
- Add a per-assembly Themes/Generic.xaml to each WPF leaf that merges the shared template and
  binds it to that assembly's TransitioningContentControl via a bare clr-namespace; the
  .Reactive assembly now ships its own themes/generic.xaml theme dictionary.
- Previously ReactiveUI.WPF.Reactive shipped no themes/generic.xaml, so the control's default
  template was never found and ViewModelViewHost stayed blank.
- Add a theme-template resolution test that runs against both WPF assemblies.

Closes #4394
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: ViewModelViewHost does not have Template (ReactiveUi.WPF.Reactive)

1 participant