What is the difference between StaticResources and DynamicResources in WPF?

What is the difference between StaticResources and DynamicResources in WPF?

EDIT: This code in the XAML file:

<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>

below code is in the resource dictionary file

<Style x:Key="ComboBoxStyle" TargetType="{x:Type ComboBox}">

    <Setter Property="FocusVisualStyle" Value="{StaticResource ComboBoxFocusVisual}"/>

    <Setter Property="Foreground" Value="#FF436B13"/>
</Style>
+3
source share
2 answers

Dynamic resources are evaluated when they are used. Static resources are evaluated at boot time.

From MSDN :

, , , , . StaticResource , . , , . DynamicResource , , , .

, .

+6

:

" " {ComboBoxFocusVisual} ". . " cmbItem " "

, ComboBoxFocusVisual ComboBoxStyle, StaticResource . , , DynamicResource

+2

Source: https://habr.com/ru/post/1717620/


All Articles