Introduction to Attached Behaviors in the context of MVVM

image 

There is also a great and yet simple article that shows how attached behaviors is used to capture an element’s right-click event and Bind it to a MVVM ICommand property.

Introduction to Attached Behaviors in the context of MVVM

Download demo project

For example, suppose that the user searches through a TreeView for an item whose display text matches a user-defined search string. When the search logic finds a matching item, the matching ViewModel object will have its IsSelected property set to true. Then, via the magic of data binding, the TreeViewItem associated with that ViewModel object enters into the selected state (i.e., its IsSelected property is set to true, too). However, that TreeViewItem will not necessarily be in view, which means the user will not see the item that matches their search string. So how can we have the TreeViewItem brought into view when the ViewModel determines that it is in the selected state.

The ViewModel objects have no idea that a TreeViewItem exists, and is bound to them, so it does not make sense to expect the ViewModel objects to bring TreeViewItems into view. The question becomes, now, who is responsible for bringing a TreeViewItem into view when the ViewModel forces it to be selected?

Attached Behaviors

The solution to the problem explained above is to use an attached behavior. Attaching a behavior to an object simply means making the object do something that it would not do on its own.

The idea is that you set an attached property on an element so that you can gain access to the element from the class that exposes the attached property. Once that class has access to the element, it can hook events on it (e.g. TreeViewItem’s Selected event) and, in response to those events firing, make the element do things that it normally would not do. It is a very convenient alternative to creating and using subclasses, and is very XAML-friendly.

So how do we attach the behavior to every TreeViewItem in the TreeView? 
By adding a Setter to the Style applied to every TreeViewItems
<TreeView.ItemContainerStyle>
  <Style TargetType="{x:Type TreeViewItem}">
    <!--
    This Setter applies an attached behavior to all TreeViewItems.
    -->
    <Setter 
      Property="local:TreeViewItemBehavior.IsBroughtIntoViewWhenSelected" 
      Value="True" 
      />

Introduction to Attached Behaviors in WPF – CodeProject

Understand your code using Dependency Graphs, Sequence Diagrams and the Architecture Explorer

ArchitectureExplorer

Have you ever had to work with a legacy codebase?  Designing new functionality on existing applications can be daunting.  There are always differences between the original design and the current implementation.  The new Architecture tools within Visual Studio 2010 help you to understand the application you have, design new functionality you need, and validate that your design and your implementation do not deviate.  In this post, we’ll look at how to understand the application that you have. 

More…

Create a Silverlight Client using OData and Bing Map

image

Part 1

Part 2 – turn into a Windows Phone 7 Client

 

In summary, this is what we’ll be doing now.

  1. Creating a Silverlight project
  2. See how to consume oData in Silverlight
  3. Use NerdDinner oData endpoint to pull Dinners and RSVPs from our Silverlight client
  4. Show them in a Bing map using Bing’s Silverlight Map SDK by geo-coding the addresses
  5. Enable our Silverlight application to run Out of Browser

We’ll be using the following technology stack. All these downloads are free for you.

7 Great Principles for Dealing with Haters

image

  1. It doesn’t matter how many people don’t get it. What matters is how many people do.
  2. 10% of people will find a way to take anything personally. Expect it.
  3. “Trying to get everyone to like you is a sign of mediocrity.” (Colin Powell)
  4. “If you are really effective at what you do, 95% of the things said about you will be negative.” (Scott Boras)
  5. “If you want to improve, be content to be thought foolish and stupid.” (Epictetus)
  6. “Living well is the best revenge.” (George Herbert)
  7. Keep calm and carry on.

Via Tim Ferriss: 7 Great Principles for Dealing with Haters

30 Tips for Successful Communication as a Remote Worker

 image

Show consideration
  • Set up calls at mutually workable hours. Avoid blocking calendars with local meetings during shared hours. Fridays are often a poor choice.
  • Start on time. Leaders should set up the bridge or Live Meeting before the call starts. Attendees should always show up on time.
  • If you can’t make it, cancel or decline least 18 hours in advance. Changing your plans to attend a non-existent meeting is very frustrating. Think carefully if the recipient will see your cancellation in time (they may be asleep).
  • Assume the best. If the other team isn’t meeting your expectations, it’s probably because of a lack of awareness or a misunderstanding—not incompetence. Clarify and confirm before drawing conclusions or judging.
Use the right tools
  • Choose the right tool. Office Communicator is great for 1-1s and small group meetings. LiveMeeting is usually better for large group meetings.
  • Use video.  Seeing faces increases the quality of the communication. It also helps create focus, preventing people from getting distracted, having side conversations, checking their email, etc.
  • In a group, use a RoundTable.  As well as enabling video, the noise-cancelling mics it has are excellent.  Make sure all your meeting rooms have one, including the satellite mics.
  • On your own, use a headset.  The sound quality for both parties is far superior.
  • Don’t use your laptop microphone. Laptop microphones are poor quality and pick up noise from your laptop’s fan, disk, and keyboard. Use the mic on your webcam or, better yet, an external mic.
  • Be a black-belt Ninja with the tools.  Make sure you can set up and join meetings quickly so that they start on time. Learn all the available features. Set up time to sit with your local team to practice and explore.

Fore more visit –> Scott Hanselman – 30 Tips for Successful Communication as a Remote Worker

RIA Services – Enterprise Patterns with WCF RIA Services

 

A common question in the RIA Services forums is how RIA Services fit into best practices architecture. I was always impressed with the basic forms-over-data capabilities of RIA Services, but I definitely saw the opportunity to better architect my application so the framework concerns didn’t leak into the logic of my application.

Fore more -> RIA Services – Enterprise Patterns with WCF RIA Services

Patterns for Parallel Programming with the .NET Framework

 image

This document provides a detailed and in-depth tour of support in the Microsoft® .NET Framework 4 for parallel programming. This includes an examination of common parallel patterns and how they’re implemented without and with this new support in the .NET Framework, as well as covering best practices for developing parallel components utilizing parallel patterns.

This document was written by Stephen Toub from the Parallel Computing Platform team at Microsoft. It is based on the .NET Framework 4 and Visual Studio 2010. Two versions of the document are available, one with code samples in C# and one with code samples in Visual Basic.

Via Download details: Patterns for Parallel Programming with the .NET Framework