Browse Source

Update README.md

pull/10407/head
Artyom V. Gorchakov 6 years ago
committed by GitHub
parent
commit
53942a551e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      README.md

12
README.md

@ -1,4 +1,4 @@
> **Warning** This is just a proof of concept, don't use it for production purposes! There are no unit tests in this project yet. Also, this project hasn't been extensively tested with any other app except for the `XamlNameReferenceGenerator.Sandbox` app.
> **Warning** This tool hasn't been extensively tested, so use at your own risk.
### C# `SourceGenerator` for Typed Avalonia `x:Name` References
@ -13,9 +13,10 @@ So in your project file you write the following code:
<Compile Update="**\*.xaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
</Compile>
<EmbeddedResource Include="**\*.xaml">
<AvaloniaResource Include="**\*.xaml">
<SubType>Designer</SubType>
</EmbeddedResource>
</AvaloniaResource>
<!-- Note this AdditionalFiles directive. -->
<AdditionalFiles Include="**\*.xaml" />
</ItemGroup>
@ -47,7 +48,7 @@ public partial class SignUpView : Window
### What do the generated sources look like?
For the [`SignUpView` view class](https://github.com/worldbeater/XamlNameReferenceGenerator/blob/main/XamlNameReferenceGenerator.Sandbox/SignUpView.xaml#L6) from [the sandbox project](https://github.com/worldbeater/XamlNameReferenceGenerator/tree/main/XamlNameReferenceGenerator.Sandbox), we get the following generated output:
For the [`SignUpView` view class](https://github.com/worldbeater/XamlNameReferenceGenerator/blob/main/src/XamlNameReferenceGenerator.Sandbox/Views/SignUpView.xaml) from [the sandbox project](https://github.com/worldbeater/XamlNameReferenceGenerator/tree/main/XamlNameReferenceGenerator.Sandbox), we get the following generated output:
```cs
// <auto-generated />
@ -75,7 +76,7 @@ namespace XamlNameReferenceGenerator.Sandbox
The typed `x:Name` references might be useful if you decide to use e.g. [ReactiveUI code-behind bindings](https://www.reactiveui.net/docs/handbook/data-binding/):
```cs
[GenerateTypedNameReferences] // Coolstuff!
[GenerateTypedNameReferences] // UserNameValidation and PasswordValidation are auto generated.
public partial class SignUpView : ReactiveWindow<SignUpViewModel>
{
public SignUpView()
@ -83,7 +84,6 @@ public partial class SignUpView : ReactiveWindow<SignUpViewModel>
AvaloniaXamlLoader.Load(this);
this.WhenActivated(disposables =>
{
// Coolstuff!
this.BindValidation(ViewModel, x => x.UserName, x => x.UserNameValidation.Text)
.DisposeWith(disposables);
this.BindValidation(ViewModel, x => x.Password, x => x.PasswordValidation.Text)

Loading…
Cancel
Save