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

Add documentation explaining how to use ReactiveUserControl in XAML #1855

Merged
merged 2 commits into from
Dec 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/ReactiveUI/Platforms/windows-common/ReactiveUserControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,33 @@ namespace ReactiveUI
/// ]]>
/// </code>
/// </para>
/// <para>
/// Note that UWP projects do not support the <c>TypeArguments</c> attribute. The XAML designer window in WPF projects also does not
/// support generic types. To use <see cref="ReactiveUserControl{TViewModel}"/> in XAML documents you need to create a base class
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to do it this way. The xaml designer is do fragile I gave up on it years ago. So might be worth saying more like "to use the base class"

Copy link
Contributor Author

@jorisvergeer jorisvergeer Dec 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't compile in an UWP (it does in WPF) project when you just use ReactiveUserControl. The xaml designer is an extra for me.

/// where you derive from <see cref="ReactiveUserControl{TViewModel}"/> with the type argument filled in.
/// <code>
/// <![CDATA[
/// internal class YourViewBase : ReactiveUserControl<YourViewModel> { /* No code needed here */ }
///
/// public partial class YourView : YourViewBase
/// {
/// /* Your code */
/// }
/// ]]>
/// </code>
/// Then you can use this base class as root in your XAML document.
/// <code>
/// <![CDATA[
/// <views:YourViewBase
/// x:Class="views:YourView"
/// xmlns:rxui="http://reactiveui.net"
/// xmlns:views="clr-namespace:Foo.Bar.Views"
/// xmlns:vms="clr-namespace:Foo.Bar.ViewModels">
/// <!-- view XAML here -->
/// </views:YourViewBase>
/// ]]>
/// </code>
/// </para>
/// </remarks>
/// <typeparam name="TViewModel">
/// The type of the view model backing the view.
Expand Down