WPF_Markup的几种写法
1. The StackPanel or child elements of the StackPanel can make use of these resources in one of two ways, both involving the StaticResource markup extension. The first Button accesses the resource using property element syntax for FontSize with an element of StaticResource and an attribute of ResourceKey to indicate the key of the item:
<Button.FontSize> <StaticResource ResourceKey="fontsizeLarge" /> </Button.FontSize>
The more common syntax is shown for the second Button. The FontSize attribute is set to a string with the words StaticResource and the key name all enclosed in curly brackets:
FontSize="{StaticResource fontsizeSmall}"
2. Let's experiment a bit with the BindLabelToScrollBar.xaml file. Although the terms source and target seem to imply that changes in the source element (in this case, the ScrollBar) precipitate changes in the target element (the Label), that's only one of four possible binding modes. You specify the mode you want by using the Mode property and members of the BindingMode enumeration. This is the default:
Content="{Binding ElementName=scroll, Path=Value, Mode=OneWay}"
Notice that the setting of the Mode property is separated from the Path property setting by another comma, and that no quotation marks appear around the BindingMode enumeration member OneWay. If you prefer the property element syntax, you add it to the attributes in the Binding element:
<Label.Content> <Binding ElementName="scroll" Path="Value" Mode="OneWay" /> </Label.Content>
浙公网安备 33010602011771号