I am working with a Windows Phone 8.1 Silverlight application that has instances of various controls on the page, buttons, check boxes, radio buttons, etc. and a slider.
Each control has an event handler added as follows, this example is specific to the slider, but other controls just replace the type of control and the actual event handled:
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);
}
}
I can download the app to the phone using visual Studio 2013 and everything works as expected, when I press buttons or move the slider I see the logging messages I expect to see.
At some point I accidentally pressed the camera button on the phone and my app was deactivated and the camera app activated. I switched back to my app and all the controls except the slider continue to produce events!
What am I missing here? I've tried several events for the slider, manipulation completed, lost focus, value changed, and they all stop being delivered after the app is reactivated, but events from all other controls are still being delivered.
Updated to include an XAML fragment defining the controls:
<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>