CollectionView is an object that we generally use while dealing with a collection in WPF. It is an object structure that supports a collection as well some of the inherent features which a user might always need while dealing with a collection. Some of the features like Sorting, Grouping, Filtering are automatically implemented in a CollectionView. I have written one article on how to deal with CollectionView way back in Aug 2010 which explains almost everything you need to do while dealing with collection in WPF. But it does not give the entire story.
Controls that can show a Collection in WPF is somehow derived from ItemsPresenter. The ItemsPresenter has a property called ItemsSource which takes an object of ICollectionView, and hence it is one of the important interfaces considered so far.
There are some advanced scenarios where the general Grouping or sorting does not makes sense. Here in this article I am going to deal with such advanced scenarios which might be worth mentioning.
Handy Tricks and Tips to do your .NET code Fast, Efficient and Simple. Some common questions that comes into mind. Please check if you could find them listed or not.
Showing posts with label XAML. Show all posts
Showing posts with label XAML. Show all posts
Tuesday, July 9, 2013
Monday, October 31, 2011
Layout adjustments Snapping and OrientationChanges in Metro Applications
If you have read my first article on Windows 8 metro styled application, you might already know about the working principle of it. I have talked about the capabilities for an application and settings which end user can configure for an application. In this post I will take a look at the basic layout structure that one needs to follow while creating an application in WinRT Metro styles so that it is best suited to perform well.
Layout is the most important part of any application. The best design for an application gets more credit and love from the users than applications that are designed bad. Metro style applications runs in full screen. Your application does not include a Title Bar, status bar or anything. Microsoft gave us some of the basic layout guidelines that one needs to follow. Lets talk about them here to make you understand how you should layout your application in Metro Applications to utilize maximum flexibility of it.
Layout is the most important part of any application. The best design for an application gets more credit and love from the users than applications that are designed bad. Metro style applications runs in full screen. Your application does not include a Title Bar, status bar or anything. Microsoft gave us some of the basic layout guidelines that one needs to follow. Lets talk about them here to make you understand how you should layout your application in Metro Applications to utilize maximum flexibility of it.
Sunday, October 30, 2011
Understanding basic WinRT Metro Applications and Application Capabilities
Just about a month ago, WinRT was introduced with all new style of application development that can work better with Multi Touch Enabled devices. We call it as Metro Applications. In this post, I will discuss how to develop your first metro applications and how to work with its layout changes.
How to Start
Before we start talking directly about Metro Style application, let us see how to install it first. I refer to use OracleVM which you can find for free from this link, and install. This will install a Virtual Machine in which you can install the Developer Preview of Windows 8.
How to Start
Before we start talking directly about Metro Style application, let us see how to install it first. I refer to use OracleVM which you can find for free from this link, and install. This will install a Virtual Machine in which you can install the Developer Preview of Windows 8.
Monday, September 12, 2011
Writing a Custom ConfigurationSection to handle a Collection
Configuration is one of the major thing that you need to keep in mind while building any application. Either its an Windows Forms application or a Web site, configuration file is always needed. We write all the configuration that are needed to be changed after it is being deployed in confugration files. It is an XML File which lists all the configuration blocks itself and also allows you to define your own custom configuration sections yourself. Today I am building my own custom configuration section and show how easily you can build yourself.
While dealing with Configurations, there are two things that you need to address
For most of the simple configurations, it is pretty much common to use these two classes, but when you need more complex configuration block, like appsettings which actually puts a Collection of ConfigurationElements, you might need to use ConfigurationElementCollection to hold the collection of ConfigurationElement.
- ConfigurationSection
- ConfigurationElement
- ConfigurationElementCollection
For most of the simple configurations, it is pretty much common to use these two classes, but when you need more complex configuration block, like appsettings which actually puts a Collection of ConfigurationElements, you might need to use ConfigurationElementCollection to hold the collection of ConfigurationElement.
Labels:
.NET,
.NET 4.0,
architecture,
beyondrelational,
C#,
CodeProject,
Configuration,
WPF,
XAML
Thursday, September 1, 2011
31 Tips for the month on Threading, WPF, MEF, ASP.NET
Daily .NET Tips is aiming to sharing useful coding tips and tricks for .NET Developers. This site completely design for sharing Tips and Tricks, useful Code Snippet which anyone use in daily development work and targeted anything related with .NET. This month we have wide range of tips including Threading, MEF, WPF and MVC. In this post I am quickly listing down all the tips which are published over the month August 2011. And the most important point to mention, among those 31 tips that has been posted on DailyDotnettips this month 22 is coming from me.
- Working with AggregateCatalog in MEF
- Working with DirectoryCatalog in MEF
- Working with AssemblyCatalog in MEF
- Working with TypeCatalog in MEF
- How to use DebuggerTypeProxy while debugging your sensitive Type
- ASP.NET Calendar Control as Outlook Calendar
- Initialize assemblies using PreApplicationStartMethod for ASP.NET 4.0 Application
- Async Lambda Expression
- Playing with ASP.NET List Controls using jQuery
- How to allow user to input html in ASP.NET MVC?
- Using Mutex to avoid deadlocks
- Writing inline Code in WPF
- What is SynchronizationContext all about
- ThreadLocal storage in .NET
- Barrier in .NET 4.0
- Use of Interlocked in Race Condition
- Call ASP.NET Page Methods using your own AJAX
- Use of SpinLock for ThreadLocking
- Using ReaderWriterLock over Monitor for Thread Locking
- What is the use of IsBackground property of Thread?
- Enable Address Level Debugging in Visual Studio
- Get List of all Control Types in WPF
- How to apply simple faded transparent effects on WPF controls ?
- Use Visual Studio Server Explorer to Add New or Existing SQL Server CE Database
- Co-Ordinated Thread Shutdown with and without using CancellationTokenSource
- Generate thousand of request
- Writing a Stretchable ContentControl in WPF
- How to Retrieve WPF Visual Tree Programmatically ?
- What is Visual Tree and Logical Tree in WPF?
- Dealing with HWND in WPF
- Hosting a WPF control inside a Windows Form
To get regular updates visit http://dailydotnettips.com and follow @dailydotnettips at Twitter.
I hope you would like the posts. Stay tune for more.
Labels:
.NET 4.0,
architecture,
ASP.NET 4.0,
C#,
MEF,
Patterns,
Reflection,
Threading,
tips,
WPF,
XAML
Monday, August 15, 2011
.NET Tips : List of my short tips
Hi Friends,
As I have already told you that I have been publishing short tips in DailyDotnetTips regularly, it is time to share the links with you to keep you updated. Please read these short tips from me and give your feedback.
As I have already told you that I have been publishing short tips in DailyDotnetTips regularly, it is time to share the links with you to keep you updated. Please read these short tips from me and give your feedback.
- Using ReaderWriterLock over Monitor for Thread Locking
- What is the use of IsBackground property of Thread?
- Co-Ordinated Thread Shutdown with and without using CancellationTokenSource
- Writing a Stretchable ContentControl in WPF
- What is Visual Tree and Logical Tree in WPF?
- Dealing with HWND in WPF
- Hosting a WPF control inside a Windows Form
- Accessing local assemblies in XAML
- Difference between a UserControl and a CustomControl
- Hosting a Windows Forms control inside a WPF
- Use x:Shared to write your FrameworkElements directly as Resource
- Use BitmapScalingMode to ensure your rendering of Image is perfect
- Object hierarchy of NULL
- Lazy Initializer to defer expensive Object creation in .NET 4.0
- Working with Co-Variance and Contra-Variance in .NET 4.0
- Using Complex Numbers in .NET 4.0
- Working with BigInteger in .NET 4.0
- Working with SortedSet in .NET 4.0
- Common Table Expressions in SQL Server
- Compiler directive #Pragma reference
So here are my last 20 short tips posted on DailyDotnetTips.
I hope you will like these tips. For full list of all the tips and the latest updates, check this link.
Happy Coding.
Thanks.
Sunday, July 31, 2011
Internals of Dependency Property in WPF
WPF introduces new property system to us. Every WPF objects that is inherited from DependencyObject inherently supports Dependency property containers within it. That means you can define your own dependency property in your code which can take part in some of the interesting features of WPF like Binding, Styles, Triggers, Animation, Property Inheritence etc. Today I will concentrate on how Dependency Property system is actually built and what are the benefits we get instead of using CLR property system.
Note : If you are really new in WPF and don't know about Dependency Property, it would be nice to read my post on Dependency Property or you can also try WPF Tutorial series to start on.
So lets start on using the most basic code of creating your own Dependency Property.
Note : If you are really new in WPF and don't know about Dependency Property, it would be nice to read my post on Dependency Property or you can also try WPF Tutorial series to start on.
So lets start on using the most basic code of creating your own Dependency Property.
Labels:
.NET,
.NET 3.5,
.NET 4.0,
architecture,
beyondrelational,
C#,
CodeProject,
internals,
Patterns,
WPF,
XAML
Sunday, July 24, 2011
Writing a Reusable Custom Control in WPF
In my previous post, I have already defined how you can inherit from an existing control and define your own reusable chunk. The reusable XAML code that I have defined there is actually a composition of one of more existing elements in a common design surface. But sometimes you must define a new behaviour for your reusable component which does not belong to any of the already existing behaviors. Custom controls can help you in this. You can define a new behaviour for your Custom control which can have a default look and feel defined for it, and obviously which can be changed using Template for the user who is using the control. In this post I am going to provide you step by step approach on defining a Custom Control for your application.
Note: If you are really new to WPF, please read my WPF Tutorial before going further.
Steps to Create a new Custom Control
Creating a custom control is very simple. Just in your project right click and add a new Item. In the dialog box that appears, choose Custom Control template and Name it. I call it here as SimpleControl.
Once you have added the control, it adds up a new class to your project which inherits from Control. The Template also provides you with some initial help to define your own control. Lets remove all the comments for now and start building a control.
Download Sample Code
Note: If you are really new to WPF, please read my WPF Tutorial before going further.
Steps to Create a new Custom Control
Creating a custom control is very simple. Just in your project right click and add a new Item. In the dialog box that appears, choose Custom Control template and Name it. I call it here as SimpleControl.
Once you have added the control, it adds up a new class to your project which inherits from Control. The Template also provides you with some initial help to define your own control. Lets remove all the comments for now and start building a control.
Download Sample Code
Labels:
.NET 4.0,
beyondrelational,
C#,
CodeProject,
Custom Control,
MVVM,
windowsclient.net,
WPF,
XAML
Saturday, July 23, 2011
Writing a Reusable WPF Control with Design Support
Code reusablity is one of the major concern to many of us. When dealing with large projects, modularizing your project is one of the primary thing that you should look for. I have talked about many of the approaches that you can use to deal with modularizing your code, eg, Prism. In this post our intent is not to talk hard on some pattern, rather I will discuss how your WPF application supports code reusability. There are a number of approaches that WPF supports to deal with reusable component. We can use Resources to define a Resource or even use CodeBehind to write our reusable component or even load the XAML from a file using XAML Loader. Each of the approaches has its own pros and cons. Today I will show you another cool technique to write a reusable XAML for your project which will allow you to easily use Visual Studio design surface to design the component.
Note : It is a very basic article, if you want to know about details on WPF, please read my tutorial on it.
Steps to Create your Reusable Component
Lets create a series of steps to create a reusable component for your application to make it easier for you to write one yourself.
Note : It is a very basic article, if you want to know about details on WPF, please read my tutorial on it.
Steps to Create your Reusable Component
Lets create a series of steps to create a reusable component for your application to make it easier for you to write one yourself.
Labels:
.NET 3.5,
.NET 4.0,
architecture,
C#,
MVVM,
windowsclient.net,
WPF,
XAML
Sunday, June 5, 2011
Working With Prism 4.0 (Hello World Sample with MVVM)
Modularity is one of the primary concern when working with a big projects. Most of us think of how we can implement our application that could be reusable across more than one applications. Patterns and Practices Team puts forward the notion of modularity with the help of Unity and Prism which most importantly focus on WPF and Silverlight applications. Being a WPF developer, it would be nice to take this apart and explain you a bit of how you can implement your application using Prism.
Before you begin, I must tell you, this is the most basic article that guides you step by step how you can write your first Prism based application and what are the advantages of building such kind of application. I will take this further in my next posts to make more concrete samples. So if you know the basics of how you can work with Prism, I would recommend you to read my next posts.
Also I assume you have some knowledge of Unity, WPF and MVVM to get you through with Prism.
Where do I find Prism?
Prism is a framework introduced by Patterns and Practices Team which is available from here. After you install your bits, you will get a folder named Prism on your local drive. After you are done, lets start coding.
Before you begin, I must tell you, this is the most basic article that guides you step by step how you can write your first Prism based application and what are the advantages of building such kind of application. I will take this further in my next posts to make more concrete samples. So if you know the basics of how you can work with Prism, I would recommend you to read my next posts.
Also I assume you have some knowledge of Unity, WPF and MVVM to get you through with Prism.
Where do I find Prism?
Prism is a framework introduced by Patterns and Practices Team which is available from here. After you install your bits, you will get a folder named Prism on your local drive. After you are done, lets start coding.
Labels:
.NET,
beyondrelational,
C#,
CodeProject,
design pattern,
Patterns,
Prism,
Unity,
WPF,
XAML
Monday, May 2, 2011
Creating Animated Splash screen in Windows Phone 7
Creating a beautiful splash screen is always great to see for any application. Windows Phone 7 being no exception to it, you want to give the user great look and feel while loading the application using your Splash Screens. In this article, I am going to spend some time by talking about some of the probable options that you have to create your own Splash Screen for your windows phone 7 application.
What is Splash Screen?
Splash screen is the first screen that comes as an introduction to the application before the application gets on executing. During the application loads up into memory there are lot of things happen in background. The process is created in memory, memory blocks are allocated, Virtualized File System gets initialized etc. During these phase of loading the application, the application hung up and the user sees the black screen. If this wait becomes too long, the user gets frustrated and might stop using the application as well. The Mobile Marketplace also puts a threshold of 10 seconds in which your application must load, otherwise your application will be rejected from App Store. During this phase, if you show some nice little splash screen to the user without hampering the normal loading of the application, the user will feel much more comfortable with your application.
In this post I will demonstrate how you can create / use splash screen for your windows Phone 7 application and the different approaches available to you for this.
Basically there are two options available before you which will allow you to show your customized splash screen :
What is Splash Screen?
Splash screen is the first screen that comes as an introduction to the application before the application gets on executing. During the application loads up into memory there are lot of things happen in background. The process is created in memory, memory blocks are allocated, Virtualized File System gets initialized etc. During these phase of loading the application, the application hung up and the user sees the black screen. If this wait becomes too long, the user gets frustrated and might stop using the application as well. The Mobile Marketplace also puts a threshold of 10 seconds in which your application must load, otherwise your application will be rejected from App Store. During this phase, if you show some nice little splash screen to the user without hampering the normal loading of the application, the user will feel much more comfortable with your application.
In this post I will demonstrate how you can create / use splash screen for your windows Phone 7 application and the different approaches available to you for this.
Basically there are two options available before you which will allow you to show your customized splash screen :
Labels:
.NET,
async,
beyondrelational,
C#5.0,
CodeProject,
MVVM,
silverlight,
Windows Phone7,
XAML
Saturday, April 30, 2011
How to Customize On-Screen Keyboard Layout in Windows Phone 7 application ?
While you want to enter some text in your Windows Phone 7 application, the first thing that you will notice is your very own on – screen keyboard. As Windows Phone 7 mobile have a very large screen area, most of the phones does not have an analog keyboard associated with it. Hence your application should provide provision to handle keyboard events directly using on-screen keyboards. There are few flexibilities available to you while you define your input scope, in this post I will demonstrate them with an example.
What is InputScope?
InputScope is a special functionality to the developers to customize how the layout of the keyboard appear to the user while entering data into that particular textbox. Hence you can easily customize the On-Screen Keyboard for your input so that one can easily feed in data fast and easy. For instance, say if you want to take phone number as input,you need only digits and some special characters to be available, on the other hand, email needed alphanumeric characters with @ as symbol. Silverlight introduces the new option to let you specify the InputScope for a particular input. Lets look into the code below :
What is InputScope?
InputScope is a special functionality to the developers to customize how the layout of the keyboard appear to the user while entering data into that particular textbox. Hence you can easily customize the On-Screen Keyboard for your input so that one can easily feed in data fast and easy. For instance, say if you want to take phone number as input,you need only digits and some special characters to be available, on the other hand, email needed alphanumeric characters with @ as symbol. Silverlight introduces the new option to let you specify the InputScope for a particular input. Lets look into the code below :
Labels:
.NET,
C#,
CodeProject,
silverlight,
Windows Phone7,
XAML
Thursday, April 28, 2011
Async support for Silverlight and WP7
Async support in C# language brings the new life to the modern application development to bring forth the same technique of writing your code and bring asynchrony easily. The main focus of async ctp is to ornament the language in such a way so that the developer could seamlessly create applications that brings asynchrony yet not dealing with its complexity. Hence using the new technique, asynchrony could easily achieved in a program without refactoring the whole program with lots of callbacks and method calls. I have already talked about it in a separate article. If you don’t know, please visit “Async CTP 5.0”.
Async CTP is released again recently and announced in MIX 11. Just after it is released, the first thing that everyone looks for is what is new in the release. As a matter of fact, I did jumped back to see them but eventually found out that there is nothing new in this build in terms of new features is concerned but the release focuses on fixes of performance adding debugging capabilities etc. I will definitely look back to them later in another post, but in this post I am going to talk about another important thing that featured with this release. As opposed to the previous release, the current release now supports Silverlight and Windows Phone 7 environments. This seems to be interesting.
What is Asynchrony?
The word asynchrony means something that is running without blocking other operations running in parallel. If you have created a background Thread to process some data, you are actually doing asynchronous job in background as your foreground operation does not get hampered. In vNext C# introduces Asynchrony using TPL. The two new keywords “async” and “await” could be used to make one sequential method asynchronous. Hence the new way of developing asynchronous program replaces the traditional approach where we needed to refactor the code totally to gain asynchrony in our application. Basically, this is done using the StateMachine to store the entire method into a form of states, and each states are delegated into batch of statements. The Task.ContinueWith is used in the system to ensure that the method body gets executed sequentially. Yes, it’s a compiler trick. If you want to know more about it, please read through my entire article on “Async CTP”.
Async CTP is released again recently and announced in MIX 11. Just after it is released, the first thing that everyone looks for is what is new in the release. As a matter of fact, I did jumped back to see them but eventually found out that there is nothing new in this build in terms of new features is concerned but the release focuses on fixes of performance adding debugging capabilities etc. I will definitely look back to them later in another post, but in this post I am going to talk about another important thing that featured with this release. As opposed to the previous release, the current release now supports Silverlight and Windows Phone 7 environments. This seems to be interesting.
What is Asynchrony?
The word asynchrony means something that is running without blocking other operations running in parallel. If you have created a background Thread to process some data, you are actually doing asynchronous job in background as your foreground operation does not get hampered. In vNext C# introduces Asynchrony using TPL. The two new keywords “async” and “await” could be used to make one sequential method asynchronous. Hence the new way of developing asynchronous program replaces the traditional approach where we needed to refactor the code totally to gain asynchrony in our application. Basically, this is done using the StateMachine to store the entire method into a form of states, and each states are delegated into batch of statements. The Task.ContinueWith is used in the system to ensure that the method body gets executed sequentially. Yes, it’s a compiler trick. If you want to know more about it, please read through my entire article on “Async CTP”.
Labels:
.NET,
architecture,
async,
beyondrelational,
C#,
C#5.0,
CodeProject,
debugging,
design pattern,
IsolatedStorage,
silverlight,
Windows Phone7,
XAML
Wednesday, April 27, 2011
Application Bar for your Windows Phone 7
If you are working with Windows Phone 7, the first thing that you should have noticed is the very own Application bar. Application Bar is present in most of the applications that you use in your Windows Phone 7. This is basically a standard Toolbar with a menu associated with it which allows you to enumerate the commonly used commands in a standard location. While creating your application, Microsoft strongly recommends you to add an application bar, to ensure the user have common behaviour for every application. You can think Application bar similar to TaskBar of windows.
Components of Application Bar
An application Bar is made up with two components:
1. ApplicationBar Buttons
2. ApplicationBar Menu
The applicationbar buttons are always visible for an application which is used to list only the items that needed to be frequently used while dealing with the application. Lets say you create a Text processing application, you can list the File->Open and File-Save commands as ApplicationBarButtons.
ApplicationBarMenu pops up when the user clicks on either the blank space of the application bar or the special button with 3 dots. The Application Menu is used to list the items that are not used often but needed sometimes in the context.
Components of Application Bar
An application Bar is made up with two components:
1. ApplicationBar Buttons
2. ApplicationBar Menu
The applicationbar buttons are always visible for an application which is used to list only the items that needed to be frequently used while dealing with the application. Lets say you create a Text processing application, you can list the File->Open and File-Save commands as ApplicationBarButtons.
ApplicationBarMenu pops up when the user clicks on either the blank space of the application bar or the special button with 3 dots. The Application Menu is used to list the items that are not used often but needed sometimes in the context.
Labels:
.NET,
beyondrelational,
C#,
CodeProject,
silverlight,
Windows Phone7,
XAML
Sunday, April 24, 2011
Working with Isolated Storage for Windows Phone 7
During the last few days, Microsoft is getting more and more inclined towards improving the user experience in more than a number of technologies. Silverlight being one of the major forerunner on this moving good in Web by providing Rich Internet Applications for end users. But not only for Web, Silverlight is a language being used for Windows Phone 7 as well, which gives the silverlight developers a chance to move over to Windows Phone easily. Being a WPF developer, I am totally freaked out on watching stuffs related to Windows Phone as richness in UI always attracts me. I have learned a few about Windows Phone 7 as well, but never got a chance to speak about it. Lets speak a little about the use of Isolated Storage (if you have already read my article here), in Windows Phone 7 in this article.
Isolated Storage
We say Files and Folders are the building blocks for any application. We need to store data in our Phones to persist data when the application is not running. In case of Windows Phone 7 microsoft provides a secure way to store data into Isolated Store. Isolated Storage, as the name suggests is a special virtualized file system that every application can access for standard IO operations yet the file is unavailable to any other application. Hence the files stored by one application is isolated from another.
Each application has a root of the store of this Virtualized File system. You can use the store to create folders and files. The main advantage of the Isolated store is independence between the actual file system and the application. Hence it gives a strong decoupling between the actual physical architecture of the system and the application. To understand, lets see the image below :

Here we have three applications running on Windows Phone, and each accesses its own root in the Virtualized file system for data storage. The application API cannot access the physical file system, but interacts with the Virtualized File system for its I/O operations. Thus if our physical file system changes, our stores will still be available and our application will run independently.
Isolated Storage
We say Files and Folders are the building blocks for any application. We need to store data in our Phones to persist data when the application is not running. In case of Windows Phone 7 microsoft provides a secure way to store data into Isolated Store. Isolated Storage, as the name suggests is a special virtualized file system that every application can access for standard IO operations yet the file is unavailable to any other application. Hence the files stored by one application is isolated from another.
Each application has a root of the store of this Virtualized File system. You can use the store to create folders and files. The main advantage of the Isolated store is independence between the actual file system and the application. Hence it gives a strong decoupling between the actual physical architecture of the system and the application. To understand, lets see the image below :
Here we have three applications running on Windows Phone, and each accesses its own root in the Virtualized file system for data storage. The application API cannot access the physical file system, but interacts with the Virtualized File system for its I/O operations. Thus if our physical file system changes, our stores will still be available and our application will run independently.
Labels:
beyondrelational,
C#,
CodeProject,
IsolatedStorage,
MVVM,
Windows Phone7,
XAML
Subscribe to:
Posts (Atom)
Author's new book
Abhishek authored one of the best selling book of .NET. It covers ASP.NET, WPF, Windows 8, Threading, Memory Management, Internals, Visual Studio, HTML5, JQuery and many more...
Grab it now !!!
Grab it now !!!