C# Support
UI Samples in C#
These samples demonstrate how to use WebSharper.UI to build reactive web applications in C#. You can compare them with the F# equivalents.
Reactive variables
Differences from F#:
View.Map2is available as an extension method instead of a static method.Vars andViews can be embedded as content directly in HTML combinators likedivbuttonhas a simplified overload that accepts the text and action directly.
Shorthand Views with .V
- Lensing on C# records is supported, so
input(state.V.Name)creates aninputelement with two-way immutable binding to theNameproperty of thestaterecord. - Instead of a
Vfunction, theV.Vhelper is used to create reactive expressions.
HTML templates
- The C# version sets
ClientLoad = FromDocumentin a HTML comment, for the templating code generator to use. - The
ListModeltype requires a key for each element, so we use a C# tuple with named elements. - C# template holes do not automatically support the
.Vshorthand, so theV.Vhelper is used.
Client-side routing
- The endpoints must be declared as a base class, and subclasses that are nested inside it. This enables
Router.Inferto work. - Fullly qualified names are used for the
RouterandDoctypes for disambiguation. This is intended to be improved in the future. See the issue.