Developing a WPF/Silverlight application using the MVVM (Model-View-ViewModel) pattern is a real challenge. But you know that using this pattern you write low-coupled and fully testable code (I hope). As MVVM says, the View can contain only XAML declarations. That is, no code-behind is present in your .xaml.cs file. Continue Reading…
Have you ever tried to extend ItemsControl in WPF/Silverlight? I guess the answer is Yes. In many situations you need to create a custom control, which support items. In this case you can use either ItemsControl or ListBox as a base. ItemsControl provides a couple of methods to help you build your items control. Such methods are IsItemItsOwnContainerOverride, GetContainerForItemOverride and PrepareContainerForItemOverride. When you add items to your control these methods are being called to help you manage your items. But have you run is such situation that when you added items these methods were not called? Well, it’s a very strange situation really. Here is you should make sure when you encounter this problem:
- make sure you are extending ItemsControl
- make sure your ItemsSource actually has items
- make sure the control is visible
- make sure you have put ItemsPresenter in the Template of your control
ItemsPresenter specifies where items should be placed, so always make sure you have placed it along other controls in the Template of your items control.
Have you ever wondered what is the difference between Timer and DispatcherTimer in WPF / Silverlight? In this post I will try to explain you the little difference. Timer generates recurring events in an application. DispatcherTimer is a timer that is integrated into the Dispatcher queue which is processed at a specified interval of time and at a specified priority. Timers are not guaranteed to execute exactly when the time interval occurs, but are guaranteed not to execute before the time interval occurs. This is because DispatcherTimer operations are placed on the Dispatcher queue like other operations. When the DispatcherTimer operation executes, it is dependent of the other jobs in the queue and their priorities. Continue Reading…