我有一個<Style x:Key="ToggleButtonStyle" TargetType="ToggleButton">
它有一個TextBlock
在裏面。我希望ToggleButton
能夠在引用樣式時更改TextBlock
的Text
屬性。我怎樣才能做到這一點?Silverlight從引用對象中改變樣式屬性
我的風格是如下
<Style x:Key="ReturnToggleButton" TargetType="ToggleButton">
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="#FF999999"/>
<Setter Property="Background" Value="#FFECECEB"/>
<Setter Property="Foreground" Value="#FF999999"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="3"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Background="Transparent">
<VisualStateManager.VisualStateGroups>
...
</VisualStateManager.VisualStateGroups>
<TextBlock x:Name="text1" TextWrapping="Wrap" Text="Open" Foreground="#FF35393D" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="10" FontFamily="Verdana"/>
<Border x:Name="border1" BorderBrush="#FF999999" BorderThickness="1" CornerRadius="1" Height="14" Width="36" Margin="6,0" Background="Transparent">
<TextBlock x:Name="text2 TextWrapping="Wrap" Text="9:30" Foreground="#FF999999" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="10" FontFamily="Verdana"/>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
我需要能夠設置的text1
和text2
這個問題需要更多的細節,顯示包含提到的TextBlock的xaml。 – AnthonyWJones
已編輯原創帖子 – Aks