Windows Presentation Foundation
The MediaElement control is used to play media contents in Technologies like WPF, Silverlight, WinRT and Windows Phone.
You might have the need to play a content forever, with a loop. A very easy way to accomplish this is Handling the MediaEnded and restart from there.
For example, we declare a boolean variable to store the loop state (enabled/disabled):
Private isLoop As Boolean = False
This can be useful if we associate the state of the loop to a button, which is just responsible to change its value:
Private Sub LoopButton_Click(sender As Object, e As EventArgs)
isLoop = Not isLoop
End Sub
Somewhere else we'll start playing the content; the important thing is how we handle the event, like in the following example:
Private Sub Media1_MediaEnded(sender As Object, e As RoutedEventArgs) Handles Media1.MediaEnded
If isLoop = True Then
Me.Media1.Position = New TimeSpan(0)
Me.Media1.Play()
End If
End Sub
Basically the code...
A few days ago, we have released my first eBook called "Hidden WPF: Secrets for creating great applications in WPF":
Published by InformIT (the online division of my publisher SAMS/Pearson), this is a different publication. It's a very small book, 99 pages, produced and thought for mobile devices. Here you will find tons of tips & tricks, suggestions, and real world implementations that I collected in my daily work, building applications with Windows Presentation Foundation.
Price is $ 7,99. You will find many info about working with PDF and XPS documents, suggestions to get the most out of the Visual Studio IDE with WPF, enhancing...
I'm pleased and proud to announce that my new book "Visual Basic 2012 Unleashed" is available, both paperback and digital edition!
This time I had the honor of featuring Lucian Wischik, the VB Specification Lead at Microsoft, as the author of a great foreword.
As usual, it has really been a hard work, but fortunately working with a great team (including Matthew Kleinwaks as the tech editor) makes things easier. The book has been fully updated to target the .NET Framework 4.5 and the new features in the Visual Basic programming Language, such as the Async/Await pattern, new tools in the...
I just released onto CodePlex a new tool called Azure Blob Studio 2011. This tool provides an easy way to manage files on your Windows Azure's blob storage, including both the online and developer accounts; it is available in two editions:
stand-alone WPF client
extension for Visual Studio 2010 (precisely a tool window)
The stand-alone client is available via a ClickOnce installer, whereas the extension is available as a VSIX package from the Visual Studio Gallery (and the Extension Manager tool in VS). With this approach you can receive updates easily.
The application has...
When working with the DataGrid in WPF, you generally use the DataGridTextColumn object for displaying or editing text. Such an object has a limitation: there is no property for specifying that the text should be automatically wrapped according to the column width, similarly to what you can do in Microsoft Excel.
Fortunately the solution is pretty easy. In fact you can use the DataGridTemplateColumn element (a generic object which allows deep customizations for cell templates) and inside it you implement one TextBox for text editing and one TextBlock for displaying text; such controls expose the TextWrapping property that we can use for wrapping the text.
Here's the...
Following the last part of the blog post introductory series on MVVM in WPF 4 applications with Visual Basic 2010, I think that you can find useful the full list of 10 posts for easier reading. Here they are:
"WPF: Introducing the Model-View-ViewModel pattern for Visual Basic 2010 developers"
Part 1 (introduction)
Part 2 (command logic)
Part 3 (details view + generic RelayCommand)
Part 4 (data validation)
(From part 5 on, MVVM is against the ADO.NET Entity Framework)
Part 5 (Entity Data Model creation + data validation)
Part 6 (Message Broker and commanding)
Part 7 (service layer)
Part 8 (creating ViewModels)
Part 9 (refactoring + unit testing)
Part 10 (Views definition, UI and code download)
I'm planning some further blog posts...
This is definitely the last blog post of the introductory series about the Model-View-ViewModel in WPF with Visual Basic 2010, particularly against the ADO.NET Entity Framework. I will explain how to build the user interface and how to bind it to ViewModels. Although this is the last blog post of the series, this does not mean that I will no longer discuss MVVM with VB 2010. On the contrary this will be an important topic for this blog, but for the sake of clarity I will distinguish topics in different blog posts and today we will complete the sample application. You can find...
So far we wrote a lot of code, in this blog post series related to MVVM in WPF with Visual Basic 2010. Of course there are a lot of things to improve before heading to the last part. This will also allow us discovering a great benefit from using MVVM, which is writing unit tests against the ViewModel. Let's start by refactoring some code.
Refactoring time!
Refactoring the code is something that is mainly about both ViewModels. OrdersViewModel is the one requiring more attention. The first thing we want to improve is how the code uses the RelayCommand class: since we also wrote a...
Let's go ahead with our discussion about the MVVM pattern in WPF applications with VB 2010. Last time I explained how to implement a service layer; in this post I will focus on ViewModels. Particularly I will show where to place an instance of the Messenger class and then I will show all the required ViewModels. Because of this it will be a quite long work, especially in terms of lines of code since concepts have all been explained in this previous post.
Send me a message!
In all tutorials I found (and studied) declaring an instance of the Messenger class...
Let's retake our journey through the MVVM pattern in WPF 4, with Visual Basic 2010, against ADO.NET Entity Framework. Last time we saw how to implement a Messenger class, describing what it is for although we'll see such a class in action in my next post. In this article we will write some code for data access which is important to understand how complex can be building applications based on the MVVM but also how many benefits it can bring into your developer life.
Problem of the day: does the ViewModel know what's the data source?
I confessed that I had to delay the...
Full Windows Presentation Foundation Archive