问题描述
限时送ChatGPT账号..我正在创建一个 Windows Phone 7.5 Silverlight 应用程序.我正在创建一个新的自定义控件:
I am creating a Windows Phone 7.5 Silverlight application. I am creating a new custom control:
public class ChartCanvas : Canvas
当我在另一个页面上使用它时,它不会触发任何事件.这是我的 XAML:
When I use it on another page, it doesn't fire any events. Here is my XAML:
<Controls:ChartCanvas x:Name="chartControl"
Margin="8"
DoubleTap="chartControl_DoubleTap"
ManipulationStarted="chartControl_ManipulationStarted" />
如何为该控件启用 DoubleTap
事件和操作事件?
How do I enable the DoubleTap
event and manipulation events for this control?
推荐答案
您可能希望将事件绑定到 datacontext 的 ViewModel,因为这将有一个通用控件,可以有不同的事件处理实现.
You probably would want to bind your events to your datacontext's ViewModel since this would have a control that is generic that can have different implementation of handling the events.
>
除非您在代码后面的 ChartCanvas 中明确编码 DoubleTap/ManipulationStarted 的逻辑并且不希望它是通用的,例如用于处理数据/东西,那么这应该没问题
Unless you explicitly coded in the ChartCanvas behind the code the logic for DoubleTap/ManipulationStarted and don't want it to be generic e.g. for handling data/stuff then this should be fine
这篇关于如何在自定义控件中启用操作事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论