Tag: WPF

The image cannot be decoded. The image header might be corrupted

I was recently trying to send to Telerik’s image editing control a jpeg image in a stream format. I was checking for the other types and using the appropriate format providers, but I kept getting an exception when working with JPEGs : The image cannot be decoded. The image header might be corrupted With the following code : So, I...

Filter an ObservableCollection with a CollectionView in C#

Using an ObservableCollection and need to filter its contents? A quick and easy way I found was to create and bind to a CollectionView to perform the filtering for you. Step 1 : Create the Observable Collection The first step is to create the observable collection. This will work for objects or system type lists, so feel free to use...

Saving and Loading a Byte Array To File in C#

Need a quick way to save a byte array to file and read back? So did I, and thought I’d include this simple code snippet for anybody who needed it as well. Includes Code : Saving to File Note below, there are two additional options (besides the name) you can include in the FileStream, FileMode and FileAccess. FileMode lets you...

The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.

Have you ever assigned a value to an IEnumerable from a database, then try to access in a foreach or something similar and get the following? “ObjectDisposedException was unhandled by user code : The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.” If you are using a using statement with your entity context,...

Quick Formatting Tips in Visual Studio 2010

Formatting code not only keeps OCD programmers like me sane being organized, it also helps with the readability of your code when ever you or somebody else views it for maintenance. However sometimes formatting the code quickly in Visual Studio 2010 is not exactly straight forward so I thought I’d give a few tips from what I learned so far,...

Open Documents and Media in WPF’s Web Browser Control in C#

Ever need to display a word document in the same application and didn’t want to shell execute word? Ever need to display text from a rich text file or regular text file? How about quickly displaying an image file? All of these could use there own controls in WPF (Document Viewer, Image control, etc..), however if you use the web browser...

Replacing Names Quickly in Visual ‘s Find and Replace

Part of the perks of moving your application to MvvM, you dont have to name your controls since you are binding everything. This frees up resources when running your application. Since my application was fairly large, I decided to dabble in Visual ‘s regular expression to replace all the names. I ended up putting :  

%d bloggers like this: