I'm trying to play audio in background, I have made a project using MVVM light Desing pattern. After some research I found this sample that helped to implement playbackagent in windows phone 8.1!
My goal is to implement the Agent in my solution with MVVM Pattern.
Could someone help me with that?
I can provide some general rules:
Put business logic / condictional code into the ViewModel.
Your View (.xaml.cs) files should only have minimum and necessary code for UI
Use the service locator to always have one instance of the music player (which can be warped inside a controller).
Use Messenger service to send data / notify the player from difference view models
Related
This question is not related to the MediaElement—pertaining to this, I’ve read both MediaElement.play() from within ViewModel and MVVM pattern violation: MediaElement.Play(), and I agree with both of them.
But say that we’re using instead a third-party assembly such as NAudio. We don’t have to find a way of plugging an existing XAML media control’s interactive features into our ViewModel. Instead, we can simply use, e.g., InteractionTriggers in our View, subscribe to it in our ViewModel, and invoke the play command on a given media file.
Now my question is: is this still something that fits, within the MVVM pattern, into the ViewModel? Or should we rather hand this down to the Model and play the file from there?
I would say it entirely depends on the nature of the media file and its relation to your app's core logic.
Is it just a UI feedback sound effect that gets played when you click on something? Stays in the view.
Is it a music player app that plays music from a playlist? That's core logic and belongs in the VM.
If I'm unsure where something lives, I think about an imaginary "view" on my app that uses a text console rather than WPF. If the logic still exists even if driven by a console, then it lives in the VM.
I have an application which has multiple UI Web, WPF, android. But I am a WPF developer. For WPF I know that MVVM pattern is best for WPF but for others I don't know.
I don't think I can use MVVM in Web and android application. How should I implement this so that same DomainModel can be used in all three UI application.
Kindly suggest.
I have created a trading application in WPF, for which I am ashamed of it's shabby look since it is far from being impressive.
I would now like to redesign the user interface for my application, and make it similar to an example screen shot of a trading application
Can someone please advice tips on what path I should follow to make a UI of similar nature? eg., if there is an open source C# WPF application which has a similar look and feel, that would be great. or if there is a library which has cool listview, scrollbar and progress bars, ..
PS: I do not have microsoft blend
You should follow the MVVM pattern for creating UI's for wpf application
http://msdn.microsoft.com/en-us/magazine/dd419663.aspx#id0090025
Refer the josh smith blog for WPF MVVM
http://joshsmithonwpf.wordpress.com/a-guided-tour-of-wpf/
Hopefully you would have completed your application by now. If not:
Try understanding the sample Stock Trader Reference Implementation application by MSDN built using WPF, MVVM, and Prism and you would get a head start for creating your kind of UI and implementation.
You can call it as a suggestion not an answer exactly. But posting for those who are new to WPF and learning screen designing or patterns. According to my experience with WPF I can say first get you hands dirty learn how binding works because that is the base of WPF.Simpler way to learn how binding works is learning how to bind controls with other controls. Then use simple classes and learn MVVM. Next go for command binding within MVVM perimeter. Keep the prism to the last, because you need good understanding of binding mechanisms, commands, MVVM and more to understand PRISM. After this you will have idea of how these things work together and will help you figure out how to play with data and screen together and design nice screens. Again, Not an answer to the above question. Just suggestions to those who are learning WPF and landed here looking for WPF UI designing.
for developing a application in C# windows application which one is better MVC or creating class file for each form
Right now the suggested direction for a Windows application would be WPF using the MVVM patern (Model, View, View Model). There seems to be a good match between WPF and use of a View Model by way of declarative binding and other nice stuff.
There are articles here: http://karlshifflett.wordpress.com/mvvm/ that should point you in the right direction plus stuff on Channel9 and elsewhere.
If you are using WPF, ModeL View Presenter (variation of mvc) is the best choice. In case of Windows Forms MVC is unnatural but still you can emulate it partially with this technology.
I am about to write a front end app, which will be used as a media center app. It will plug directly into a high definition TV. Essentially transforming my laptop into a media player. While this concept is not new, I want custom functionality, so this is why I am not reusing existing products.
I'm a C# developer, so the app should ideally be written in C#. And there is 1 other consideration, I need to accept input via the MCE Remote.
I was considering using Silverlight for this. Would you recommend this? Or any other recommendations for frameworks before I begin planning around this.
Thanks in advance.
This is the type of stuff that the Windows Presentation Foundation was meant for. You'll get a lot more access to the hardware than Silverlight would provide (I.E. that MCE remote you mentioned). You mark up your UI with vector graphics/XAML, and then perform the logic with C#.
EDIT: WPF also has support out of the box for animations which can make your UI a lot more interactive.
EDIT 2: Scott Hanselman has written a really cool application called BabySmash and posted the source online. It basically intercepts keyboard input and shows shapes and sounds on the computer. It's a good "child-proofing" method for your PC. The code could provide you with some insight into WPF and how to do the animations and interactivity that you're looking for.
Is this a desktop app? If so I would use WPF. Silverlight is a subset of WPF, so using WPF you could potentially do more.
Silverlight or WPF, if you want some extra power. Both have a similar programming model (with XAML and code-behind) so you might be able to start with Silverlight and move up to WPF if you need.
The VLC api might be useful for playing your media, someone has created a C# wrapper for it:
http://wiki.videolan.org/.Net_Interface_to_VLC
WPF is certainly the way to go, and for playing media check out the excellent WPF MediaKit: http://wpfmediakit.codeplex.com/ I've used it successfully in many projects.