简体   繁体   English

如何在WPF中使用WAV文件创建数据网格

[英]How to create a datagrid with wav-files in WPF

I hope somebody could help me. 我希望有人能帮助我。 I want to add a wav-file for every object in my objectlist. 我想为我的对象列表中的每个对象添加一个wav文件。 The class is bound to an ObservableCollection. 该类绑定到ObservableCollection。 But I want to know the easiest way to read and play these wav-files from a datagrid using SoundPlayer? 但是我想知道使用SoundPlayer从数据网格读取和播放这些wav文件的最简单方法吗?

public string CoName
{
   get { return coName; }
   set 
   { 
         coName = value;
         Changed("CoName");
   }
}

public byte[] CoSound
{
   get { return coSound; }
   set 
   { 
         coSound = value;
         Changed("CoSound");
   }
}

You could use MediaElement . 您可以使用MediaElement

You should bind the Source property of MediaElement to the wav file (CoSound?). 您应该将MediaElement的Source属性绑定到wav文件(CoSound?)。

You should also define the style of the datagrid so that the column you want to put the sound on. 您还应该定义数据网格的样式,以便您要在其上放置声音的列。

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

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