ProductiveRage / Bridge.React

Bindings for Bridge.NET for React - write React applications in C#!
MIT License
74 stars 14 forks source link

Use XAML to define the Render method of components (Code-Behind pattern) #41

Closed montyclt closed 6 years ago

montyclt commented 6 years ago

Hello, I have a question / proposal.

Is possible define the Render method in XAML instead in class?

I prefer write:

MyButton.cs

public partial class MyButton : Component<MyButton.Props, MyButton.State>
{
  class Props {...}

  public MyButton() : base(new Props { }) {...}
}

MyButton.cs.xaml

<button class="my-button">{Binding children}</button>

Instead of:

public partial class MyButton : Component<MyButton.Props, MyButton.State>
{
  class Props {...}

  public MyButton() : base(new Props { }) {...}

  public ReactElement Render()
  {
    return Dom.Button(
      new Attributes { }, 
      this.children
   );
  }
}

There are any plans for support XAML?

Thanks you!

ProductiveRage commented 6 years ago

I think that there would need to be support in the Bridge compiler to support xaml and I'm not aware of them having any plans on that front.

If I'm being stupid and there is a way for Visual Studio to translate the xaml into regular .cs content that the Bridge compiler will then translate into JavaScript then it may be possible.. feel free to reopen the issue, if so!

montyclt commented 6 years ago

As I know, a xaml file is compiled into CRL class that initialize as properties its children, but I'm not really sure.