![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest
Posts: n/a
| 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 |
|
|
| |
| | #2 (permalink) | ||||||||||||
| Guest
Posts: n/a
| Re: WPF user controls interacting with each other Hello,
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 | ||||||||||||
| |||||||||||||
| | #3 (permalink) | ||||||||||||
| Guest
Posts: n/a
| Re: WPF user controls interacting with each other Serge Baltic wrote:
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 | ||||||||||||
| |||||||||||||
| | #4 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest
Posts: n/a
| Re: WPF user controls interacting with each other Hello,
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.
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.
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 | ||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||
| |
| |