ItemsControl ItemTemplate Binding

Are you sure the code you posted here IS the code you use in your solution? Because, this code works for me : XAML <ItemsControl ItemsSource=”{Binding}”> <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text=”{Binding OwnerData.OwnerName}”></TextBlock> <TextBlock Text=”{Binding Credit}” /> </StackPanel> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> Window’s Loaded Event ObservableCollection<ForDisplay> items = new ObservableCollection<ForDisplay>(); for (int i = 0; i < … Read more

Is there a Threadsafe Observable collection in .NET 4?

There are two possible approaches. The first would be to inherit from a concurrent collection and add INotifyCollectionChanged functionality, and the second would be to inherit from a collection that implements INotifyCollectionChanged and add concurrency support. I think it is far easier and safer to add INotifyCollectionChanged support to a concurrent collection. My suggestion is … Read more

Best ORM to use with C# 4.0 [closed]

UPDATE 2016 Six years later things are VERY different. NHibernate is all but abandoned, other alternatives were abandoned (eg Subsonic), Entity Framework is perhaps the most common full-featured ORM, and people have been moving to micro ORMs like Dapper for years, to map from queries to objects with a minimum of overhead. The application scenarios … Read more

GetSystemMetrics() returns different results for .NET 4.5 & .NET 4.0

So, it’s actually a by-design behavior, and if someone has similar issues, here is the code which always outputs the same result: const int CXFRAME = 0x20; const int CYFRAME = 0x21; const int CXPADDEDBORDER = 92; var dx = GetSystemMetrics(CXFRAME); var dy = GetSystemMetrics(CYFRAME); var d = GetSystemMetrics(CXPADDEDBORDER); dx += d; dy += d; … Read more

Where can I find a TPL dataflow version for 4.0?

I wrote Steve from the TPL dataflow team about this problem and he responded me with the following download link: http://download.microsoft.com/download/F/9/6/F967673D-58D6-4E3F-8CA9-11769A0A63B1/TPLDataflow.msi This is a CTP version, but the date matches the Nuget package with version number 4.0, so I think it’s the latest version that was compiled against .NET 4.0.

Checking for diacritics with a regular expression

You can use the specific Unicode escape for letters – \p{L} (this will include the A-Za-z ranges): ^[.\p{L}]*$ See on regularexpressions.info: \p{L} or \p{Letter} Matches a single Unicode code point that has the property “letter”. See Unicode Character Properties in the tutorial for a complete list of properties. Each Unicode code point has exactly one … Read more

Reverse a string with accent chars?

The problem is that Array.Reverse isn’t aware that certain sequences of char values may combine to form a single character, or “grapheme”, and thus shouldn’t be reversed. You have to use something that understands Unicode combining character sequences, like TextElementEnumerator: // using System.Globalization; TextElementEnumerator enumerator = StringInfo.GetTextElementEnumerator(“Les Misאֳrables”); List<string> elements = new List<string>(); while (enumerator.MoveNext()) … Read more