我在我的应用程序中添加了语音合成.它工作但问题是我无法取消语音...例如,当我导航到另一个页面时,语音继续...所以,我调用CancelAll()方法取消当前语音但发生异常而且我不知道为什么.你知道这是什么问题吗?
例外
A first chance exception of type 'System.Threading.Tasks.TaskCanceledException' occurred in mscorlib.ni.dll
An exception of type 'System.Threading.Tasks.TaskCanceledException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
An exception of type 'System.Threading.Tasks.TaskCanceledException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
The program '[2576] TaskHost.exe' has exited with code -1 (0xffffffff).
Run Code Online (Sandbox Code Playgroud)
我的代码:
private SpeechSynthesizer synth = new SpeechSynthesizer();
protected override void OnBackKeyPress(CancelEventArgs e)
{
//I tried to cancel also here but it's the same exception...
}
//method called when …Run Code Online (Sandbox Code Playgroud) 我有一个Listbox与一些Listboxitem,我想改变所有项目的风格.我知道,可以在资源中创建一个样式并将这个样式绑定到每个项目,但也许有可能这样做更容易(没有绑定)?使用ListBox.ItemTemplate?
<ListBox SelectionChanged="ListBox_SelectionChanged">
<ListBoxItem x:Name="ItemAdress">
....
</ListBoxItem>
<ListBoxItem x:Name="ItemPhone">
....
</ListBoxItem>
<ListBoxItem x:Name="ItemEmail">
....
</ListBoxItem>
</Listbox>
Run Code Online (Sandbox Code Playgroud)
事实上,我的目标是为每个项目添加保证金底部15.(在项目之间添加空格)