0

我正在使用一个 Windows Phone 8.1 Silverlight 应用程序,该应用程序在页面上具有各种控件的实例、按钮、复选框、单选按钮等和一个滑块。

每个控件都有如下添加的事件处理程序,此示例特定于滑块,但其他控件只是替换控件的类型和实际处理的事件:

static void instrumentSlider(Slider slider)
{
    Logger.Logger.LogMessage("instrumentSlider() - Called for: [" + slider + "]");

    slider.ManipulationCompleted -= new EventHandler<ManipulationCompletedEventArgs>(slider_ManipulationCompleted);
    slider.ManipulationCompleted += new EventHandler<ManipulationCompletedEventArgs>(slider_ManipulationCompleted);
}

static void slider_ManipulationCompleted(object sender, ManipulationCompletedEventArgse)
{
    try
    {
        Logger.Logger.LogMessage("slider_ManipulationCompleted() - Called for: [" + sender + "]");

        if (sender is Slider)
        {
            Slider slider = (Slider)sender;
            // Do stuff...
        }
    }
    catch (Exception ex)
    {
        Logger.Logger.LogException(ex);
    }
}

我可以使用 Visual Studio 2013 将应用程序下载到手机上,一切正常,当我按下按钮或移动滑块时,我看到了我希望看到的日志消息。

在某些时候,我不小心按下了手机上的相机按钮,我的应用程序被停用并且相机应用程序被激活。我切换回我的应用程序,除滑块外的所有控件继续产生事件!

我在这里想念什么?我已经为滑块尝试了几个事件,操作完成,失去焦点,值更改,并且在重新激活应用程序后它们都停止传递,但来自所有其他控件的事件仍在传递。

更新为包含定义控件的 XAML 片段:

    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <Slider Height="84" HorizontalAlignment="Left" Margin="37,243,0,0" Name="slider1" VerticalAlignment="Top" Width="383" />
        <Button Content="Button" Height="72" HorizontalAlignment="Left" Margin="27,18,0,0" Name="button1" VerticalAlignment="Top" Width="160" Click="button1_Click" RenderTransformOrigin="0.531,-0.222" />
        <CheckBox Content="CheckBox" Height="72" HorizontalAlignment="Left" Margin="241,17,0,0" Name="checkBox1" VerticalAlignment="Top" RenderTransformOrigin="0.509,0.181" />
        <HyperlinkButton Content="HyperlinkButton" Height="30" HorizontalAlignment="Left" Margin="27,110,0,0" Name="hyperlinkButton1" VerticalAlignment="Top" Width="200" />
        <ListBox Height="103" HorizontalAlignment="Left" Margin="37,342,0,0" Name="listBox1" VerticalAlignment="Top" Width="383" RenderTransformOrigin="0.499,1.408">
            <ListBoxItem Content="ListItem1" />
            <ListBoxItem Content="ListItem2" />
            <ListBoxItem Content="ListItem3" />
        </ListBox>
        <RadioButton Content="RadioButton" Height="72" HorizontalAlignment="Left" Margin="241,73,0,0" Name="radioButton1" VerticalAlignment="Top" IsChecked="True" />
        <RadioButton Content="RadioButton" Height="72" HorizontalAlignment="Left" Margin="241,126,0,0" Name="radioButton2" VerticalAlignment="Top" RenderTransformOrigin="0.528,0.056" />
        <RadioButton Content="RadioButton" Height="72" HorizontalAlignment="Left" Margin="241,171,0,0" x:Name="radioButton3" VerticalAlignment="Top" RenderTransformOrigin="0.503,1.837" />
        <TextBox Height="72" HorizontalAlignment="Left" Margin="37,445,0,0" Name="textBox1" Text="TextBox" VerticalAlignment="Top" Width="383" />
    </Grid>
4

0 回答 0