Skip to content

Make XAML style writing more like CSS #288

@JHeLiu

Description

@JHeLiu

Make XAML style writing more like CSS

  1. Less code
  2. Be more logical
  3. Easier to read

I don't know if future versions have that design in mind
Let's say I want a button with rounded corners

// version now

<Window.Resources>
      <Style x:Key="Btn" TargetType="Button">
          <Setter Property="Template">
              <Setter.Value>
                  <ControlTemplate TargetType="Button">
                      <Border BorderThickness="1" Width="60" Height="32" CornerRadius="3" Background="#4C5EE9">
                          <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center" />
                      </Border>
                  </ControlTemplate>
              </Setter.Value>
          </Setter>
          <Setter Property="Foreground" Value="#fff"></Setter>
      </Style>
  </Window.Resources>

  <Button Style="{StaticResource Btn}" Content="Button"></Button>

// expect version 1

   <Style x:Key="Btn" TargetType="Button">
         Width=60,
         Height=32,
         Background="#4C5EE9",
         Foreground="#FFF",
         BorderRadius=3
   </Style>
   <Button Style="{StaticResource Btn}" Content="Button"></Button>

// expect version 2

   <Style>
       Btn {
         Width:60,
         Height:32,
         Background:"#4C5EE9",
         Color:"#FFF",
         BorderRadius: 3
       }
   </Style>
   <Button Style="{StaticResource Btn}" Content="Button"></Button>
    OR
   <Button Class="{Btn}" Content="Button"></Button>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions