The browser-wpf-application consists of files: App.xaml, App.xaml.cs, Page1.xaml, Page1-xaml.cs.
The files: App.xaml and App.xaml.cs are clean. There is a problem in regard to the connection between Button 6 and the Click-event of Button 6.
Filename: Page1.xaml:
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="400" d:DesignWidth="600"
Title="Page1">
Filename: Page1.xaml.cs:
using System;
using System.Collections;
using System.ComponentModel;
using System.Media;//wegen der klasse "SoundPlayer"
using System.Windows;
using System.Windows.Controls;
using System.Diagnostics;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfBrowserApplication1
{
public partial class Page1 : Page
{
public Page1()
{
InitializeComponent();
btn6.Click += new RoutedEventHandler(btnButton6_Click);
btn1.Click += new RoutedEventHandler(btnButton1_Click);
///RoutedEventhandler is the basic routed event handler delegate
}
void btnButton1_Click(object sender, RoutedEventArgs e)
{
MessageBoxResult result = MessageBox.Show("Do you want to close this window?",
"Close",
MessageBoxButton.YesNoCancel,
MessageBoxImage.Question,
MessageBoxResult.No);
if (result == MessageBoxResult.Yes)
{ MessageBoxResult result2 = MessageBox.Show("Sorry, I don't know how to close the app"); }
}
void btnButton6_Click(object sender, RoutedEventArgs e)
{
InitializeSound();
}
public void InitializeSound()
{
SoundPlayer player = new SoundPlayer();
player.SoundLocation = "SampleSounds/beatuful money.wav";
player.Load();
player.Play();
}
private void txtOben_TextChanged(object sender, TextChangedEventArgs e)
{
}
}
}
Dmitrij SolovPosted May 11, 2015, 11:35 AM
the problem is:
in the description of the error I get the following message:
"WpfBrowserApplication1.Page1.btn6 is nothing assigned to. It has always the standard value of "zero".
Adinarayana Reddy JcPosted May 11, 2015, 3:56 AM
try this one..
Dipankar BiswasPosted May 10, 2015, 11:54 PM
try it
System.Media.SoundPlayer s = new System.Media.SoundPlayer();
s.SoundLocation = "C:\\mps.wav" ;
s.Load() ;
s.Play();