標籤:sch 資源 cti off rac 調用 his black 建立
這個針對異地調用:
1.在主程式的項目中建立一個Skins的目錄。然後再目錄裡建立一個BlackSkin.xaml的字典資源:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="MenuBackGround" TargetType="Grid">
<Setter Property="Background">
<Setter.Value>
<LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
<GradientStop Color="#FF282828" Offset="0.434"/>
<GradientStop Color="#9E4B2626" Offset="0.904"/>
<GradientStop Color="#FF412828" Offset="0.268" />
<GradientStop Color="#FF3A3A3A" Offset="0.061" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
假設在另外一個項目中要調用這個樣式的話。在前台加上:
<UserControl.Resources>
<ResourceDictionary Source="/Skins/BlackSkin.xaml"></ResourceDictionary>
</UserControl.Resources>
引用這個樣式:
<Grid Margin="0" Name="grid2" Grid.Row="1" Style="{StaticResource MenuBackGround}"/>
這樣就能夠實現樣式了。
當然,另一種引用就是在後台寫:
grid2.Style=this.FindResource("MenuBackGround") as Style;
wpf 樣式的調用