简体   繁体   English

音量滑块C#Windows Phone 7.1

[英]Volume slider c# windows phone 7.1

I have some problem with a slider volume in my windows phone app 7.1 我的Windows Phone App 7.1中的滑块音量有问题

this is the XAML 这是XAML

<Slider Name="volumeSlider" VerticalAlignment="Center" ValueChanged="ChangeMediaVolume" Minimum="0" Maximum="1" Value="0.5" Margin="0,146,0,-27"/>

and this the simply function ChangeMediaVolume 这就是简单的功能ChangeMediaVolume

private void ChangeMediaVolume(object sender, RoutedPropertyChangedEventArgs<double> args)
{
   AudioPlayer.Volume = (double)volumeSlider.Value;
}

If I don't have this lines all it's ok... but when they are in the code the debugger show an error. 如果我没有这些行,那么就可以了...但是当它们在代码中时,调试器将显示错误。

A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in System.Windows.ni.dll 类型“ System.Windows.Markup.XamlParseException”的第一次机会异常发生在System.Windows.ni.dll中

If there is a handler for this exception, the program may be safely continued. 如果有用于此异常的处理程序,则可以安全地继续执行该程序。

Probably this is what's wrong with it. 可能这就是问题所在。 Try changing the line 尝试换线

<Slider Name="volumeSlider" ...

to

<Slider x:Name="volumeSlider" ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM