NotifyingObject for WPF & Silverlight

Monday, October 11, 2010

There are many ways notifying on property changed, and I think the most popular one is using the lambda expression solution: public class Ball : Model { private double _velocity; public double Velocity { get { return _velocity; } set { if (_velocity != value) ...

Best Twitter Application for very fast Tweeting!

Tuesday, September 1, 2009

Last weekend I’ve tried to find a very simple twitter application for sending messages very quickly over the twitter network,  so I’ve googled something like: “Best Twitter Application for very fast Tweeting” And not surprisingly I’ve got tons of twitter applications, but neither was simple to use nor suited to my needs. So I’ve decided to create another twitter application, were “very fast tweeting” is its main goal. So far I’ve created a new open source project in CodePlex, not yet published, and uploaded a very first preview spike code for my new app called Tweet...

WPF ComboBox and C# Enum – The Love Story

Tuesday, December 11, 2007

Q: How can I bind a property of type Enum (of any kind) to a ComboBox or ListBox controls? I bet that you Googled this question more than once. Did you find the correct answer?   Well, I saw a lot of them, with code or XAML only, sorted, filtered, grouped, etc. With all the respect, I didn't get a generic answer with a two-way data-flow to a single enum-type property.   See these links as an example:   These are all great solutions for how to display a specific Enum value, but not to bind to a property of any-type of Enum (the type of the...

WPF is DPI Dependent

Friday, November 30, 2007

<Button Content="Click me!" Width="100" Height="100" /> Do you really know how many pixels in the button's width and height? Clicking F1 on Width and Height properties in Visual Studio, it is written that the "value is interpreted as a device-independent unit (1/96th inch) measurement". Now, the default value of DPI (dots per inch) in a default Windows installation with a simple Monitor is 96. Now let's calculate how many pixels you have: px = 100/96 * dpi ==> if dpi=96 then px=100, else, if dpi=120 then px=125. What does it means? It means that your UI...
tags: ,

WPF Official Image Interop

Sunday, October 14, 2007

As I wrote my few last posts about how to access the BitmapSource WIC image pixels, I have found a post in the MSDN forum, which exposes a static class called Imaging. This amazing class which somehow was very hard to find, can do a great work with image-interop. Looking inside the MSDN for the Imaging class, I found the following methods: CreateBitmapSourceFromHBitmap CreateBitmapSourceFromHIcon CreateBitmapSourceFromMemorySection The CreateBitmapSourceFromMemorySection is the best match for creating a BitmapSource from a memory section. Looking further inside the updated MSDN it said that "CreateBitmapSourceFromMemorySection - Returns a managed BitmapSource, based on the provided unmanaged memory location". When I tried...

WPF Image Processing Under the Hood

Monday, October 1, 2007

In the last two posts I have showed how to create a BitmapSource image and access its underlying WIC image, for manipulating its pixels. In this post I will explain how does the WICBitmap* works. Download the code from here. Looking inside the BitmapSource class using Reflector, it figures out that it encapsulates a WIC image (_wicSource). The WICBitmap class uses reflection to retrieve this private field: public WICBitmap(BitmapSource source) { Type bitmapSource = typeof(BitmapSource); ...

WPF Raw Video

In my last post I showed how to access the WPF's BitmapSource underlying WIC image, and I promised to explain my code, and also to post an Image stream (Video) code based on my solution. In this post I will quickly talk about the unique CompositionTarget class, and I will show how to render a Raw Video using its Rendered event. Download the code from here (FYI - I refractor the code from the last post and fixed several bugs). I will start by reminding one of the disadvantages of my WICBitmap solution: "Sometimes the Lock/Copy fail. I think that it because...

WPF Image Processing

Friday, September 21, 2007

With the release of Windows Vista and WPF, Microsoft has also released the WIC: "an extensible framework for working with images and image metadata. WIC makes it possible for independent software vendors (ISVs) and independent hardware vendors (IHVs) to develop their own image codecs and get the same platform support as standard image formats (for example, TIFF, JPEG, PNG, GIF, BMP, and WMPhoto)" (MSDN). Unsurprisingly, WPF uses WIC in its core (for example, BitmapSource). Unfortunately, the WPF team chooses to keep the WIC low level API internally, in such a way that there isn't a simple solution for dealing...

WPF Model Data Binding – Part II

Friday, September 14, 2007

In my previous post I showed how to design a data model which provides the following characteristics: Property notification changes In-memory state persistency Commit and Rollback mechanism Dirty flag In this post I will show how to handle multi-threading scenarios with WPF data binding. You can download the complete code from here. Before I will start, I want to give a little background of the WPF threading model, and to explain why you shouldn't change any data-bind object from a different thread. The WPF threading model is very simple: STA (Single Thread Affinity). This means that like other UI technologies such as Windows Forms,...
no comments

WPF Model Data Binding – Part I

Wednesday, July 25, 2007

The Data Binding concept, first introduced with Windows Forms, provides a way for decoupling the View from the Data and for eliminating the boilerplate, mass code of marshaling the data to and from the view. WPF extends this mechanism by adding some great features, especially when dealing with Data Templates, which provides an easy way for reflecting the data with view. In WPF, Data Binding is everywhere! Data binding is a great mechanism, but there are some situations that data-binding not exactly fits. In Part I of this post I will talk about such situation, and I will provide some kind of pattern that I developed...