Skip to content

Commit

Permalink
Fix For ViewModelViewHost not working on WinUI projects (#3575)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPulman committed Jul 8, 2023
1 parent 9d73fba commit 2ef3d99
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
8 changes: 2 additions & 6 deletions src/ReactiveUI.Maui/Common/AutoDataTemplateBindingHook.cs
Expand Up @@ -23,18 +23,14 @@ public class AutoDataTemplateBindingHook : IPropertyBindingHook
/// <summary>
/// Gets the default item template.
/// </summary>
[SuppressMessage("Design", "CA1307: Use the currency locale settings", Justification = "Not available on all platforms.")]
public static Lazy<DataTemplate> DefaultItemTemplate { get; } = new(() =>
{
const string template = "<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' " +
"xmlns:xaml='clr-namespace:ReactiveUI;assembly=__ASSEMBLYNAME__'> " +
"xmlns:xaml='clr-namespace:ReactiveUI'>" +
"<xaml:ViewModelViewHost ViewModel=\"{Binding Mode=OneWay}\" VerticalContentAlignment=\"Stretch\" HorizontalContentAlignment=\"Stretch\" IsTabStop=\"False\" />" +
"</DataTemplate>";
var assemblyName = typeof(AutoDataTemplateBindingHook).Assembly.FullName;
assemblyName = assemblyName?.Substring(0, assemblyName.IndexOf(','));
return (DataTemplate)XamlReader.Load(template.Replace("__ASSEMBLYNAME__", assemblyName));
return (DataTemplate)XamlReader.Load(template);
});

/// <inheritdoc/>
Expand Down
3 changes: 1 addition & 2 deletions src/ReactiveUI.Maui/Common/ReactiveUserControl.cs
Expand Up @@ -74,9 +74,8 @@ namespace ReactiveUI
/// <typeparam name="TViewModel">
/// The type of the view model backing the view.
/// </typeparam>
[SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "Deliberate usage")]
public
class ReactiveUserControl<TViewModel> :
class ReactiveUserControl<TViewModel> :
UserControl, IViewFor<TViewModel>
where TViewModel : class
{
Expand Down

0 comments on commit 2ef3d99

Please sign in to comment.