그래서 나는 즉시 (RegularPolygon 정확히) 컨트롤을 만들려고 해요 및 이벤트 이벤트를 기반으로 EventTrigger 컨트롤로 2 PlaySoundActions 추가하고 싶습니다. '시스템 에 'Microsoft.Expression.Interactivity.Media.PlaySoundAction '에서 변환 할 수 없습니다 : 각 행은이 인수 1SoundActions가있는 EventTrigger를 코드 뒤에 추가하는 방법은 무엇입니까?
오류와 같은 오류가
EventTrigger trigger = new EventTrigger(); PlaySoundAction correct = new PlaySoundAction(); PlaySoundAction incorrect = new PlaySoundAction(); correct.Source = new Uri("/Sounds/Correct.mp3"); correct.Volume = 0.5; incorrect.Source = new Uri("/Sounds/Incorrect.mp3"); incorrect.Volume = 0.5; trigger.Actions.Add(correct); // this line doesn't work trigger.Actions.Add(incorrect); // this also doesn't work shape.Triggers.Add(trigger);
: 현재 나는 다음과 같은 코드가 있습니다 .Windows.TriggerAction '
PlaySoundAction 개체를 어떤 형식으로 캐스트해야할지 모르겠습니다. XAML에서이 컨트롤을 즉시 만들고 있기 때문에이 작업을 수행하고 싶지 않습니다.
또한 RegularPolygon의 스타일을 만들어서 PlaySoundAction을 사용하여 EventTrigger를 만들려고했으나 프로그래밍 방식으로 컨트롤의 스타일을 설정해도이 논리가 컨트롤에 추가되지 않았습니다.
<Application.Resources>
<ResourceDictionary>
<Style TargetType="es:RegularPolygon" x:Key="Default">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Tap">
<eim:PlaySoundAction Source="/Sounds/Incorrect.mp3" Volume="0.5" />
<eim:PlaySoundAction Source="/Sounds/Correct.mp3" Volume="0.5" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Style>
</ResourceDictionary>
</Application.Resources>
뒤에 코드에서 EventTrigger/PlaySoundAction를 추가하거나 제어가이 EventTrigger/PlaySoundAction을 가지고에서 상속 할 수있는 스타일을 만들 수있는 방법이 있나요?
문서는 어쩌면 PlaySoundAction은 필요하지 않습니다 조치 BeginStoryboard 개체의 컬렉션 말한다? http://msdn.microsoft.com/en-us/library/system.windows.eventtrigger.actions(v=VS.95).aspx –