2012-03-16 65 views
0

我有,我用下面的代碼代替鼠標光標與csuomt Silverlight應用程序:Silverlight的鼠標事件停止工作,如果自定義光標使用

用戶控件:CustomC.xaml

<UserControl...> 
    <Canvas> 
    <Image x:Name="EGCursor" Visibility="Collapsed"></Image> 
    </Canvas> 
</UserControl> 

用戶控件:CustomC.xaml.cs

public void SetSource(string resource) 
{ 
    EGCursor.Source = new BitmapImage(new Uri(resource, UriKind.Relative)); 
    EGCursor.Stretch = Stretch.None; 
} 
    public void MoveTo(Point pt) 
{ 
    EGCursor.Visibility = Visibility.Visible; 
    EGCursor.SetValue(Canvas.LeftProperty, pt.X - 13); 
    MyCursor.SetValue(Canvas.TopProperty, pt.Y - 12); 
} 

個MainWindow.xaml

<UserControl x:Class="SL.MainPage"... Cursor="None"> 
... 
</UserControl> 

MainWindow.xaml.cs

MainWindow() 
{ 
CustomC = new CustomC(); 
CustomC.SetSource("GlowingCur.png"); 
LayoutRoot.Children.Add(CustomC); 
} 

void MainPage_MouseMove(object sender, MouseEventArgs e) 
{ 
    CustomC.MoveTo(e.GetPosition(null)); 
} 

在做好上面的自定義光標,在我的Silverlight MouseLeaveMouseClick等點擊事件的所有停止工作。我該如何糾正這種行爲,以便只更換鼠標光標,並且其他已經編碼的事件工作相同?

回答

0

嘗試在您的自定義光標控制設置IsHitTestVisible爲false:

CustomC = new CustomC(); 
SutomC.IsHitTestVisible = false; 
CustomC.SetSource("GlowingCur.png"); 
LayoutRoot.Children.Add(CustomC);