按钮向下&举办活动

时间:2013-05-27 20:25:07

标签: button event-handling windows-phone-8

我刚开始使用Windows Phone 8开发。 在正常的winforms中,我可以做一个OnMouseDown和OnMouseUp。

这将如何转化为WP8开发?如果按下按钮,我需要触发某些东西,当它被释放时我需要触发其他东西吗?

2 个答案:

答案 0 :(得分:3)

请根据您的要求尝试操作启动和操作完成的事件。

        public MainPage()
        {
            InitializeComponent();
            button.ManipulationStarted += button_ManipulationStarted;
            button.ManipulationCompleted += button_ManipulationCompleted;         
        }

        void button_ManipulationCompleted(object sender, System.Windows.Input.ManipulationCompletedEventArgs e)
        {
            textblock.Text += "\n mouse button up";
        }

        void button_ManipulationStarted(object sender, System.Windows.Input.ManipulationStartedEventArgs e)
        {
            textblock.Text += "\n mouse button down";
        }

答案 1 :(得分:0)

我刚刚使用了事件MouseLeftButtonDown和MouseLeftButtonUp