1
這好像應該是簡單的,但我不能讓它發生......我有一個模板列,其中包括一個按鈕一個DataGrid:按鈕風格
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource LinkButton}" Content="{Binding Path=...}"/>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
和我的LinkButton的風格是這樣的:
<Style x:Key="LinkButton" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<ControlTemplate.Resources>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="TextDecorations" Value="Underline" />
</Style>
</ControlTemplate.Resources>
<ContentPresenter />
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Foreground" Value="Blue" />
<Setter Property="Cursor" Value="Hand" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Foreground" Value="Red" />
</Trigger>
</Style.Triggers>
</Style>
當選擇該行,我想LinkButton的的前景顏色更改爲白色或東西。有沒有簡單的方法來完成這個?
神奇, 非常感謝。還有其他的東西在網格和列中強制我使用模板列。我在設計時嘗試了超鏈接,但無法使其工作。我認爲這是因爲我需要發送一個命令給視圖模型,在這一點上我不記得了。 – drowned