tabcontrol+media element

Posted by Jayakumarkm under WPF on 4/8/2010 | Views : 1959 | Status : [Member] | Replies : 3
hi
im working with 3.5 wpf window application,c#
i have tabctl wit 3 tabitems(tab1,tab2,tab3).
i have media element in tab2.

i have source uri in a table as 5th column(hosanna.mp3)..on selecting the corresponding row the media element should play(hosanna.mp3)..

when i select tab2 i need to play song when change the change it shud not played..

how to that...
regarda
jai




Responses

Posted by: Vuyiswamb on: 4/8/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Right click your tab and go to properties and go to the event button and look for the GotFocus Event , and double click on it to create a handler and

on mine i write

private void tabItem3_GotFocus(object sender, RoutedEventArgs e)
{
MessageBox.Show("HELLO WORLD");
}


easy tell me if you have a problem.

Thank you for Posting at Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Jayakumarkm, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumarkm on: 4/8/2010 [Member] Starter

Up
0
Down
thanks

but i dont have my events for my controls at wpf windows application...

i couldnt solve it..


Jayakumarkm, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 4/9/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Then Create them, show me your Xaml file.

Mine looks like this

<Window x:Class="WpfApplication2.Window1"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<Grid Margin="50,69,39,124">
<TabControl Margin="0,0,-52,-31" Name="tabControl1">
<TabItem Header="tabItem1" Name="tabItem1"></TabItem>
<TabItem Header="tabItem2" Name="tabItem2"></TabItem>
<TabItem Header="tabItem3" Name="tabItem3" ContextMenuOpening="tabItem3_ContextMenuOpening" GotFocus="tabItem3_GotFocus"></TabItem>
</TabControl>
</Grid>
</Grid>
</Window>

and my cs looks like this

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
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 WpfApplication2
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}

private void tabItem3_ContextMenuOpening(object sender, ContextMenuEventArgs e)
{

}

private void tabItem3_GotFocus(object sender, RoutedEventArgs e)
{
MessageBox.Show("HELLO WORLD");
}
}
}



you need to create the event.

Thank you for posting at Dotnetfunda
[Administrator]

Jayakumarkm, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response