Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - WPF user controls interacting with each other

 
 
Old 12-27-2007   #1 (permalink)
Eps


 
 

WPF user controls interacting with each other

Hi,

I am writing an mp3 player using wpf, I have three user controls (media
library, media controls and a playlist). Obviously I need these to
interact with each other, I assume the best way to do this is to use
events right ?.

Can I raise an event on one user control and have one of the others
suscribe to it ? or do I need to have the main window suscribe to it and
then pass the message on to the target user control ?.

Any advice appreciated.

--
Eps

My System SpecsSystem Spec
Old 12-27-2007   #2 (permalink)
Serge Baltic


 
 

Re: WPF user controls interacting with each other

Hello,
Quote:

> I am writing an mp3 player using wpf, I have three user controls
> (media library, media controls and a playlist). Obviously I need
> these to interact with each other, I assume the best way to do this is
> to use events right ?.
I don't think the controls should be interacting with each other at all.

Besides the controls, the program should have a data model — some kind of
data structures for the media library, one section of which represents a
playlist, and the current status of the player. The controls reflect the
current state of the data model by the means of databinding, and they change
the model with databinding and commanding. They do not have to know anything
of each other, or of the window they belong to.

(H) Serge


My System SpecsSystem Spec
Old 12-27-2007   #3 (permalink)
Eps


 
 

Re: WPF user controls interacting with each other

Serge Baltic wrote:
Quote:

> I don't think the controls should be interacting with each other at all.
>
> Besides the controls, the program should have a data model — some kind
> of data structures for the media library, one section of which
> represents a playlist, and the current status of the player. The
> controls reflect the current state of the data model by the means of
> databinding, and they change the model with databinding and commanding.
> They do not have to know anything of each other, or of the window they
> belong to.
>
> (H) Serge
I have a datable in the medialibrary control that contains (amongst
other things) the path of every song. Are you suggesting I create a new
object which encapsulates the datatable as well as exposing more
properties (like the play/pause/stop status and the current song, etc.)

I guess all the controls could then just bind to relevent properties of
the object.

I have played about a bit with data binding, how do you go about binding
to an objects property ?.

--
Eps

My System SpecsSystem Spec
Old 12-29-2007   #4 (permalink)
Serge Baltic


 
 

Re: WPF user controls interacting with each other

Hello,

Quote:

> I have a datable in the medialibrary control that contains (amongst
> other things) the path of every song. Are you suggesting I create a
> new object which encapsulates the datatable as well as exposing more
> properties (like the play/pause/stop status and the current song,
> etc.)
There're built-in means for binding to databases, their specific queries
and views. That fits nicely into the task of presenting the media library,
which is basically a database view. The only extra information you need is
the current selection, which affects the Play action.
Quote:

> I guess all the controls could then just bind to relevent properties
> of the object.
Yes. The object gives out the database connection, which gets presented as
a list, gets back the selection info, handles play/stop/pause commands. Logically,
the database object and the playback object should better be separate entities,
but that's an implementation detail.
Quote:

> I have played about a bit with data binding, how do you go about
> binding to an objects property ?.
The "{Binding}" markup extension has a source and a path relative to the
source. If the source is the object itself, then the path is just the property
name. The source can be specified either in the binding itself or by setting
the DataContext attribute on some containing XAML element.

(H) Serge


My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
User account controls Vista security
User Account Controls Vista security


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46