I try to make a button image change when it is Pressed, Normal and Disabled, this is my XAML code:
<Button x:Name="Open" Content="Open" HorizontalAlignment="Right" Margin="442,0,0,0" VerticalAlignment="Top" Width="75" Height="20" Click="Open_Click" IsDefault="False" IsEnabled="True">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<Image x:Name="Normal" Source="../Resources/o_b.png" Visibility="Visible"/>
<Image x:Name="Pressed" Source="../Resources/o_b.png" Visibility="Hidden"/>
<Image x:Name="Disabled" Source="../Resources/o_b.png" Visibility="Hidden"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="Normal" Property="Visibility" Value="Hidden"/>
<Setter TargetName="Pressed" Property="Visibility" Value="Visible"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Normal" Property="Visibility" Value="Hidden"/>
<Setter TargetName="Disabled" Property="Visibility" Value="Visible"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
And this is the error i have,
"Could not find a part of the path 'D:\\vs saves\\QuickImg\\Resources\\o_b.png'.
I get this same error at all lines where i try to access the image resources.
UPDATE: I solved the problem, I ain't sure what caused this problem but i just deleted the Resources folder and created a new one named Images, added the images and updated the Source in the xaml.
问题是我可能没有将o_b.png设置为资源。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.