0
我有一個資源的內部下面的樣式百科編輯樣式元素
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<Rectangle Fill="#262626" Name="Normal"/>
<Rectangle Fill="#3f3f41" Name="Hover" Visibility="Hidden"/>
<Rectangle Fill="#007acc" Name="Pressed" Visibility="Hidden"/>
<Image Name="Icon"/>
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Hover" Property="Visibility" Value="Visible"/>
<Setter TargetName="Pressed" Property="Visibility" Value="Hidden"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="Pressed" Property="Visibility" Value="Visible"/>
<Setter TargetName="Hover" Property="Visibility" Value="Hidden"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
而且我需要的名字改變「源」的形象「圖標「(在我的MainWindow.xaml中)
<Button Style="{StaticResource ToolbarButton}">
<Setter TargetName="Icon" Property="Source" Value=".png"/>
</Button>
但它給我的錯誤「源無法識別或不能入店」
我怎樣才能改變我的形象的「源」屬性名稱爲「圖標」的按鈕?
謝謝,非常有用的答案 – user962284