实现效果:
实现步骤:
1、要实现鼠标选中显示边框效果,可以在Image控件重绘OnRender时绘制,这里我们重写Image控件,添加MyImage.cs类继承自System.Windows.Controls.Image,代码如下:
public partial class MyImage : System.Windows.Controls.Image
{
public MyImage()
{
}
public bool IsSelect;//是否选中
/// <summary>
/// 重绘
/// </summary>
protected override void OnRender(DrawingContext dc)
{
base.OnRender(dc);
if (IsSelect)
{
try
{
//绘制边框
Rect rect = new Rect(0, 0, this.Width, this.Height)