Jas*_*wal 3 c# wpf resources wpf-controls
WPF中的StaticResources和DynamicResources有什么区别?
编辑:XAML文件中的此代码:
<ComboBox Canvas.Left="14" Style="{StaticResource ComboBoxStyle}"
Canvas.Top="137" Height="33" Name="cmbItem" Width="170"
SelectionChanged="cmbItem_SelectionChanged">
<ComboBoxItem>Name</ComboBoxItem>
<ComboBoxItem>Age</ComboBoxItem>
</ComboBox>
Run Code Online (Sandbox Code Playgroud)
下面的代码在资源字典文件中
<Style x:Key="ComboBoxStyle" TargetType="{x:Type ComboBox}">
<Setter Property="FocusVisualStyle" Value="{StaticResource ComboBoxFocusVisual}"/>
<Setter Property="Foreground" Value="#FF436B13"/>
</Style>
Run Code Online (Sandbox Code Playgroud)