Thursday, May 10, 2018

Rapid XAML Toolkit - some questions answered

As I write this, Build has just finished. It's been a great three days but today has been the best. That's in most part due to the reception that my new project has received.


I made the repository for the Rapid XAML Toolkit public this morning.
I wrote a bit about it earlier, but here are the answers to some more questions I've repeatedly been answering today.

  • What is it? - It's the ability to generate a XAML UI from a data (or view) model based on some configurable rules. It can produce everything from the whole view, all the way down to the UI for a single property which you put where you want in an existing file. There are also some helpers for wiring up the data context (on the view or code-behind) as necessary.
  • Is it an app builder? - No, it is a developer tool. The aim is to give developers something to build upon or modify, rather than having to do everything themselves.
  • Why build it? - Lots of apps are created from the data up. They are forms on top of databases or web service requests. In these scenarios, a data model exists, and a corresponding UI is required. By removing some of the effort involved in creating the UI, hopefully, this will free more developer time to work on innovative features or fixing bugs. It's an indirect way to help more developers create better software.
  • Is it Windows/UWP only? - No, it's XAML focused and platform agnostic.
  • What does that mean? - UWP, WPF, and Xamarin.Forms!
  • It works with Xamarin? - Yes, but Xamarin.Forms only.
  • Does it work with Xamarin Native? - No, but the underlying generation engine could probably output some useful stuff. I just don't have the time to investigate how at the moment.
  • What about code-first UIs? - Again, the focus is on XAML, but it could probably generate something
  • Can it be used now? - Well, it's all open source, go for it. In reality, it's still in an Alpha stage.
  • How long until a proper release? - When it's ready. If you want to help, it'll be sooner. Hopefully not more than a couple of months though. There will be a proper beta first.
  • What about F# support? - No. It uses Roslyn CodeAnalysis to analyze the source, and this doesn't support F#. There may be some way around this, but there are other, more important things to do first. It is in the backlog, just don't hold your breath. It does work with VB though.
  • Why VB? - Because Windows.   As a tool that has a background in helping developers migrating older Windows apps to UWP, I recognize that a large number of them use VB and so I don't want to exclude them.
  • Will it work with Visual Studio for Mac? - No, just VS for Windows. This is because that's what supports development for all XAML platforms?
  • How to use it with WPF? - You'll need to create a profile first. I'll add some soon.
  • Is this a Microsoft thing? - Yes, and no. I don't work for Microsoft, but it is an open source project released under their GitHub organization. That means their name on the copyright, but it's also MIT licensed. Yes, this is unusual--it's the result of exceptional circumstances.
  • But you had a staff badge at Build? - Yes, I was working on the Windows Template Studio booth because I'm a significant contributor to that project. This is also why the development and configuration were done to support UWP first. RXT is a sister project to WTS.
  • Have there been any official announcements about this yet? - Not yet, but expect something in the next couple of weeks.
  • Are there any video, tutorials, etc.? - Not yet, but they will be coming.

Other points to note:
  • This is just the start. The name deliberately claims to be a toolkit. There are lots of other things planned, but the underlying engine opens a lot of opportunities and possibilities to build upon.
  • Yes, it would be cool to put some ML/AI in it ;) 


Go check it out now at https://aka.ms/rxt
Then ask me questions on twitter @mrlacey



Wednesday, May 09, 2018

I just "gave" a load of code to Microsoft

TLDR: Announcing a new open source project for making XAML development easier.


What's this about giving away code?

I had an idea for something, built a proof-of-concept that impressed and excited some people, and we decided that the best way to get it to lots of people quickly was for Microsoft to release it as an Open Source project. So, that means I've "given" the code to Microsoft on the basis that they'd make it open source and thereby giving it away to everyone. In practice, it means it's in a Microsoft owned repository but I'm an admin and main contributor.


What is this thing then?

Introducing the Rapid XAML Toolkit.

It's a Visual Studio extension that provides functionality to accelerate XAML development.
It's rare for developers to build the XAML UI for an app before having some sort of data model that the UI will represent and allow interaction with. It might be from a database, web service, or somewhere else but if you've got some code that describes what should be there, why not let the tool create it for you?


Of course, it's more than just a file. It contains suitable XAML that represents the ViewModel, wires up the bindings, and sets the data context. It's not going to be the final XAML you need but it's going to do in two clicks what could otherwise take a few minutes. Given the choice, would you rather have a blank page or something that works and you can just tweak to your needs?

As an example, given a class that looks like this:

    public class OrderDetailsViewModel : ViewModelBase
    {
        public int OrderId { get; private set; }
        public Guid CustomerId{ get; set; }
        public DateTimeOffset OrderDate { get; set; }
        public string OrderNotes { get; set; }
        public decimal OrderTotal { get; }
        public ObservableCollection<OrderLineItem> Items { get; set; }
    }

It could produce this:

    <StackPanel>
        <TextBlock Text="{x:Bind ViewModel.OrderId}" />
        <TextBlock Text="{x:Bind ViewModel.CustomerId}" />
        <DatePicker Date="{x:Bind ViewModel.OrderDate, Mode=TwoWay}" />
        <TextBox Text="{x:Bind ViewModel.OrderNotes, Mode=TwoWay}" />
        <TextBlock Text="{x:Bind ViewModel.OrderTotal}" />
        <ListView ItemsSource="{x:Bind ViewModel.Items}">
            <ListView.ItemTemplate>
                <DataTemplate x:DataType="OrderLineItem">
                    <StackPanel>
                        <TextBlock Text="{x:Bind OrderLineId}" />
                        <TextBlock Text="{x:Bind ItemId}" />
                        <TextBlock Text="{x:Bind ItemDescription}" />
                        <TextBlock Text="{x:Bind Quantity}" />
                        <TextBlock Text="{x:Bind UnitPrice}" />
                        <TextBlock Text="{x:Bind LineTotal}" />
                    </StackPanel>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </StackPanel>


How does it know what XAML to create?

The generated XAML is based on the type and name of the property and whether it is read-only. There are some carefully chosen options provided by default but everything is configurable. In the future, it may also be powered by AI too ;)


How does it know where to put the created file?

It's based on conventions but is fully configurable. It even supports having the View and ViewModel in different projects if that's what you prefer.


That all sounds like one feature. Why call it a toolkit?

Because there are plans for much more. XAML generation is just the start, but it enables lots of scenarios and opportunities.

Even today, it doesn't just provide the ability to produce whole files. It also provides the ability to generate XAML without having to create the file. You can generate the XAML for an entire class, an individual property, or a selection of properties. This raises the question of where the XAML will go. We leave that up to you. The generated XAML can either be copied to the clipboard (so you can paste it wherever you wish) or sent to the clipboard (so you can drag it where you want it.)

The final part of setting up the basic association between VM and View is to ensure that the data context for the page is correctly set. If it's not, then it provides the option to do this for you.








Does it do X?

Probably not...yet! There are lots of features planned but if you've got a suggestion, please raise an issue in the GitHub repository.


How does this compare to Windows Template Studio?

Windows Template Studio will help you to scaffold a UWP app. The Rapid XAML Toolkit is a sister project and can help you once you've created the stub of your app, or if you have an existing app. It doesn't have to be a UWP app either. We hope this will be helpful to Xamarin developers too.


Wait, what's this about Xamarin? I thought it was a UWP thing.

Nope, it's a XAML thing!
While there may end up being some elements or features that are UWP only, the intention is that it will be beneficial to any developer who is working with XAML. This means Xamarin.Forms and WPF. (It will work with Silverlight too, but I'm just not providing any default configuration for it.)


Really, WPF?

Yes, WPF too.


Anything else?

Yes, it works with both C# AND VB.Net.


Really, VB.Net?

Yes, because all developers deserve nice things. Plus, we think this will be particularly beneficial to developers converting WinForms and WPF apps to UWP, and we know a lot of them use VB. If they're learning UWP, they shouldn't have to learn C# as well.


Where can people find out more?

GitHub is the place. Go to https://github.com/Microsoft/Rapid-XAML-Toolkit and check out the current features.


p.s. As you'd expect, I'll be sharing more details soon, but, if you're at //build, I can show you more. You'll find me at the Windows Template Studio & Community Toolkit booth.




Thursday, May 03, 2018

Personal mission statement

I've been thinking about creating a personal mission statement. Something that simply and clearly sets a guide for what I (want to) work on.
I've come up with this.

Help people create better software.

I think there are two aspects to this: Education and Tooling.

Education
People can't make better software if they don't know what makes better software or how to create it.
I'll do this by providing resources in the form of books, articles, etc.

Tooling
Creating/providing tooling that can help create better software will make it easier and faster for people to do so.


What do I mean by "better"?

- Easier to learn
- Easier to use
- Easier to support
- Usable by more people
- Fast
- Reliable
- Robust
- Secure
- more ...


Some practicalities
- I can't help everyone.
- I'll focus (at least initially) on areas where I have specific knowledge and opportunities.