Showing posts from July, 2010

Binding to ListData (with IsSynchronizedWithCurrentItem)

Today while testing out data binding in WPF to list controls, I learnt something new.
On the window, I created two list boxes, and a textblock control all have data context of an xml static resource.
For the ItemsSource in listbox I was using: {Binding XPath=@name} [the xml resource contains a Color element with attribute 'name]. I used IsSynchronizedWithCurrentItem on both the listboxes and bound the TextBlock Text to {Binding XPath=@Name}.
On testing the app I found, the controls are not synchronized. After referring to MSDN and some testing with different bindings - I found that to enable synchronization between all the controls to the CurrentItem of the collection, it is important to bind the list boxes to the whole collection. and not to a member or attribute (in this example).
So for listboxes it should be ItemsSource={Binding}, for display purposes we can use DisplayMemberPath or DataTemplate.

Tool to download complete web site

Use this to copy a complete web site locally.
[TIP: You can use this to download channel9 videos of your interest]

Debug XAML

Important links

Events, Delegate and Multithreading
MSDN's canonical technique for using Control.Invoke is lame

Send a message to a Windows Forms message loop

SlickRun custom magic words

[msdn] Filename="$W$" Notes="Searches MSDN using Google" GUID={2F9AC37E-9BD9-486D-9168-D7C2FF0D0750} StartMode=5 UseRunAs=0 Disable32BitRedir=0 [msdngo] Filename="$W$" Notes="Goes to the first Google search item on MSDN site" GUID={E82C1293-A5C3-4D18-BBD7-BAFC543AC6EE} StartMode=5 UseRunAs=0 Disable32BitRedir=0 [n] Filename="notepad.exe" Params="$W$" GUID={B3DADC2D-B5EA-4186-B165-CDCF7F6BEF2F} StartMode=5 UseRunAs=0 Disable32BitRedir=0 [stack] Filename="" GUID={28BF5F9B-CAE3-48E9-A66E-440135239B96} StartMode=5 UseRunAs=0 Disable32BitRedir=0 [times] Filename="" Notes="The New York Times" GUID={6791C0B1-91B9-4946-BC16-07B58AEFF9DF} StartMode=5 UseRunAs=0 Disable32BitRedir=0 [wi] Filename="http://frer0342:8080/WorkItemTracking…

Dev Tools

- Slickrun:
- Process explorer:
- RocketDoc:
- Fences:
- LINQPad: (Code snippet execution)
- mTail:

Using Attributes

I just realised that we have two ways to use an attribute.
For example the attribute - AttributeUsage - is implemented in the class AttributeUsageAttribute. And we can use either AttributeUsage or AttributeUsageAttribute in our code.
In fact if you create a custom attribute in class named "TestAttribute":
public class TestAttribute : Attribute { }
and define another custom attribute named "Test":
public class Test : Attribute { }
and then try using the attribute in a class:
[Test()] public class MyClass { }
This will give compilation error: 'Test' is ambiguous between 'Test' and 'TestAttribute'; use either '@Test' or 'TestAttribute'
The code intellisense as well displays only the "Test" pointing to TestAttribute in its list, it doesn't show the other "Test".
I believe C# creates an alias of TestAttribute somewhere for the attribute. It actually makes sense to use aliased-name of attribute. It would be unwieldy to write…