Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix For ViewModelViewHost not working on WinUI projects #3575

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/ReactiveUI.Maui/Common/AutoDataTemplateBindingHook.cs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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