Copyright © 2006 - 2008 MultiMedia Soft 
Return to Table of contents  
 
 
Adding the component to a Visual Studio.NET 2008 WPF project 
 
As you are probably aware XAML & C# codebehind for Windows Presentation Foundation (WPF) does not have a container form like Winforms applications, so the controls toolbox is not available. This means you cannot just drag the control onto a form and have Visual Studio automatically instantiate it. 
The XAML code is what is used to generate the "form" and it is here that you need to instantiate our control: 
 
  • Create a "WPF Application" project, named by default "WpfApplication1" 
  • This will create two files a/ Window1.xaml & Window1.xaml.cs 
  • On the Solution Explorer sidebar, right-click the "References" section, select the "Add reference" item from the context menu and, from the "Add Reference" window, manually add the following references to the project: 
  • AudioDjStudio 
  • System.Windows.Forms 
  • WindowsFormsIntegration 
  •  
     
     
  • Modify the original XAML file with the following code: 
  •  
    <Window x:Class="WpfApplication1.Window1" 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      xmlns:as="clr-namespace:AudioSoundRecorder;assembly=AudioSoundRecorder" 
      xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" 
      xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration" 
      Title="Window1" Height="300" Width="300" 
      > 
      <Grid> 
          <wfi:WindowsFormsHost Margin="1,0,-1,0"> 
              <as:AudioSoundRecorder x:Name="audioSoundRecorder1"/> 
          </wfi:WindowsFormsHost> 
      </Grid> 
    </Window> 
     
  • This will now initialize the control when the application loads. 
  • The Window1.xaml.cs file is the codebehind file where you can then just use the control as usual, for example for initializing it and displaying its about box: 
  •  
    namespace WpfApplication1 
       /// <summary> 
       /// Interaction logic for Window1.xaml 
       /// </summary> 
       public partial class Window1 : Window 
       { 
           public Window1() 
           { 
               InitializeComponent(); 
               audioSoundRecorder1.InitRecorder(0, -1); 
               audioSoundRecorder1.AboutBox(); 
           } 
       } 
     
     
     
     
     
     
     
     
    Copyright © 2006 - 2008 MultiMedia Soft 
    Return to Table of contents