XAML 样式 与 CSS

<ResourceDictiontory Source="css/stlye.xaml"></ResourceDictiontory>

等同于

<link rel="stylesheet" href="css/style.css" />

 

代码加载xaml style

ResourceDictionary resources = null

using (FileStream fs = new FileStream(文件路径+@"style.xaml", FileMode.Open, FileAccess.Read)) 

 resources = (ResourceDictionary)XamlReader.Load(fs); 

Application.Current.Resources = resources;  

===============================================

<Style TagetType="Button">

  <Setter Property="Background" value="Red"></Setter>

  ......

</Style>

等同于

input[type="button"]{

  background:red;

  ......

}

===============================================

<Style TagetType="Button" x:Key="btn1">

  <Setter Property="Background" value="Red"></Setter>

  ......

</Style>

应用:

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

等同于

.btn1{

  background:red;

  ......

}

应用:

<input type="button" class="btn1" />

posted @ 2012-12-10 14:10  Yu  阅读(856)  评论(0编辑  收藏  举报