[英]Image Source Xaml
I try to make a button image change when it is Pressed, Normal and Disabled, this is my XAML code: 我尝试在按下,正常和禁用时更改按钮图像,这是我的XAML代码:
<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'. “找不到路径'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. 更新:我解决了这个问题,我不确定是什么引起了这个问题,但是我只是删除了Resources文件夹并创建了一个新的名为Images的图像,添加了图像并更新了xaml中的Source。
问题是我可能没有将o_b.png设置为资源。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.