Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 单击vs Hold,Hold导致语法错误_C#_Silverlight_Xaml_Windows Phone - Fatal编程技术网

C# 单击vs Hold,Hold导致语法错误

C# 单击vs Hold,Hold导致语法错误,c#,silverlight,xaml,windows-phone,C#,Silverlight,Xaml,Windows Phone,这是我的XAML: <Button x:Name = "Helloworld" Content = "Hello world" Grid.Column = "0" Grid.Row = "0" Click="playEvent"

这是我的XAML:

                    <Button x:Name = "Helloworld"
                        Content = "Hello world"
                        Grid.Column = "0"
                        Grid.Row = "0"
                        Click="playEvent"
                        Hold="setEvent"
                        Tag="/Sounds/helloworld.mp3" 
                    />
                    <Button x:Name = "Helloworld_ring"
                        Grid.Column = "1"
                        Grid.Row = "0"
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Stretch"
                        Click="setEvent"
                        Tag="/Sounds/helloworld.mp3">
                        <Image Source="/Images/note.png" Stretch="Fill" Height="30" Width="30" />
                    </Button>
据我所知,这是很难描述的。但我注意到的问题是,在调试过程中,setSrcButton变量没有获得e.OriginalSource的值,但这只在我在Helloworld上使用Hold事件时发生。当我在Helloworld_ring上使用Click事件时,一切正常


感谢所有的帮助。谢谢:)

也许e.OriginalSource不是您的按钮

在这种情况下,发送者应该是您的按钮,因此请尝试使用该按钮

 setSrcButton = sender as Button;

虽然我希望有人能解释为什么会这样,但我非常感谢你的回答。现在可以了。非常感谢。
An unhandled exception of type 'System.NullReferenceException' occurred in MyApp.dll
 setSrcButton = sender as Button;