GitXplorerGitXplorer
s

cloaked-hipster

public
12 stars
3 forks
0 issues

Commits

List of commits on branch master.
Unverified
50dcdbec3fd86b3125829be3d0fac535be420e1b

moving method out to extension

sshiftbot committed 13 years ago
Unverified
f36986fea12c19e2e457219b81760bc48880ac8b

started on R# settings file

sshiftbot committed 13 years ago
Unverified
450a0afb9c08584188d8f56508b8d23a02d871c8

extracted logic to separate assembly

sshiftbot committed 13 years ago
Unverified
9d825a3e3b8eaf252424d98445de8c705d28a5b7

added new project

sshiftbot committed 13 years ago
Unverified
d1f0f8f3b777a925bd38def565c36036c93889ee

renamed extensions class

sshiftbot committed 13 years ago
Unverified
42413f8dbc0340abcb8153c4b2bd48b7df95b51b

added some more mappers

sshiftbot committed 13 years ago

README

The README file for this repository.

cloaked-hipster

The Rant

A discussion yesterday about XAML versus HTML degenerated into much debate around how terrible the XAML syntax is for declaring resources.

<Style TargetType="TextBlock" x:Key="TitleText">
  <Setter Property="Background" Value="Blue"/>
  <Setter Property="DockPanel.Dock" Value="Top"/>
  <Setter Property="FontSize" Value="18"/>
  <Setter Property="Foreground" Value="#4E87D4"/>
  <Setter Property="FontFamily" Value="Trebuchet MS"/>
  <Setter Property="Margin" Value="0,40,10,10"/>
</Style>

So very very verbose.

Contrast that with the equivalent CSS:

titletext 
{ 
   background: blue;
   font-size: 18;
   foreground: #4E87D4;
   font-family: Trebuchet MS;
   margin: 40px 10px 10px 0; // note how the order is different
}

The Wager

So one wise-guy, who shall remain nameless, said "Why can't you just use CSS?" and after more debate I ran out of things that were dealbreakers.

So this little sandbox is an experiment - using Twitter Bootstrap as a reference stylesheet - to allow you to use CSS in your XAML apps.

The implementation

I think the best approach for this is to use T4 templates, and I've got a prototype which now works using T4:

<#@ template language="C#" #>
<#@ output extension=".xaml" #>
<#@ assembly name="$(SolutionDir)\CloakedHipster\bin\Debug\CloakedHipster.dll" #>

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<#
var conventions = new CloakedHipster.Conventions();
conventions.Use("btn", "Button");
conventions.Use("text", "TextBlock");

Write(CloakedHipster.Transformer.Generate(CssContents, conventions)); #>

</ResourceDictionary>

<#+
string CssContents = "titletext { background: blue; font-size: 18; foreground: #4E87D4; font-family: Trebuchet MS;   margin: 40px 10px 10px 0; }";
#>

And how would you use this?

  1. Open a XAML app
  2. File -> New Item -> Select "New CSS Resource" file -> Add
  3. Paste in CSS contents into value. Save file.
  4. Build process runs T4 engine and spits out a XAML resource file
  5. Reference new resource dictionary in your App.xaml file

Notes:

The use of conventions to resolve styles needs to be thought through - it feels rushed at the moment.

Integrating with the build system to provide feedback about how styles cannot be transformed

  • "style 'titletext' could not be processed as it doesn't have a control defined..."
  • "style 'titletext' has an image which is not included in the project..."

Are you mad?

According to @tathamoddie, yes.