Skip to main content

Posts

Showing posts with the label xaml

Formatting strings in binding

Recently I get a chance for a code walk through of an WPF application in order to achieve better performance. So, during my review process, I came across this below code snippet:   <WrapPanel>         <TextBlock Text="{Binding Path=FirstName,Mode=OneWay}"/>         <TextBlock Text=" "/>         <TextBlock Text="{Binding Path=LastName,Mode=OneWay}"/>     </WrapPanel> If you will closely analyze this given snippet, you will definitely get a way to optimize it. Well, I am talking  about formatting the string as well as binding part. As most of you are aware that we have a property named StringFormat since .Net 3.5 SP1. So, why can't we use this StringFormat for our binding too. If you want to change the above code to incorporate StringFormat , then it will something look like: <WrapPanel>         <TextBlock>                 <TextBlock.Text>                     <MultiBinding String

Resizing TextBlock with resizing of window

When dealing with XAML, many of you might have came across resizing issues in which your control is getting resize but the text/image inside the control is not getting resize as per the window size(it can be other user control). So, to deal with this Microsoft provide us with a Viewbox control, in which user can set the resizing aspects as per the need and requirement. So, this article focuses mainly on the properties provided by Viewbox control with proper sample code and output. MORE...

Safest way to use RaisePropertyChanged method - MVVM series 3 of n

Background In my previous post on  Simplest MVVM Ever , I gave the simplest overview of implementing MVVM. Now moving forward, I thought to extend my previous post by picking individual areas. And this time, I selected  RaisePropertyChanged . All the developers working on XAML related apps are very well aware about the use of this RaisePropertyChanged. I am sure, most of us are also aware on where to use this. But does everyone aware about what is the proper way or let's say generic way to use it ??? Well, even if you are not aware, no problem. At the end of this post, you will surely take home a useful tip on using  RaisePropertyChanged . Introduction As we know that MVVM provides a loose coupling methodology. At lot many places it is very useful to get benefit of such architecture, but at the cost of your alertness. Because when we are talking about MVVM, we usually says that ViewModel has no knowledge about View and properties are the way, who binds View and ViewModel to

Simplest MVVM Ever - MVVM series 2 of n

Continuation to my previous article on  WHY and WHEN of MVVM , this time, I am going to tell something on how we can create a simple MVVM application with minimal complexities. I am writing this article for those, who just want to see quickly how MVVM works. It doesn't do anything fancy and uses some basic databindings and commanding stuff. This article will be helpful for all those who are looking for a quick example of how to hook the View to the ViewModel and how commands plays a role.  Today if you will surf internet, you will came across 1000s of articles discussing on what is MVVM and what are the major building blocks of it. So, I am going to repeat the same crazy thing again. But definitely, I'll brief you about major building blocks in layman, in order to make it easier to understand for beginners. Excited, eh ???  Layman introduction of building blocks    So, let's quickly start with three main layers of MVVM. Model  - Model contains the classes which ar

New Features in Vistual Studio 2013 Release Candidate

It has been great movement, great work done by VS team for making easy to use Visual Studio. There has been lot of new features in Visual Studio 2013 preview, which has some very cool features in XAML, intellisence, goto definition and many more. But in RC, most of these features are extended. Today I'll try to cover as much as possible about all these new features. So, let's start by taking them one-by-one. 1)  Intellisence in XAML - Earlier versions of VS were pretty cool but I hope, whoever working in WPF would have surely miss intellisence feature. But in RC, that is no more a limitation. So, if we let editor know where the data is, it will help us out like a friend and will make our work easier. VS2013 rc supports intellisence for DataBinding and Resources . Let's have a look of this feature in below screen shot: I ntellisence for DataBinding    I ntellisence for Resources 2) Go To Definition in XAML - This new feature in available in VS2013 RC

Windows App Splash Screen - Beginners Tutorial

I ntroduction Continuing to my previous article title, here we will see about splash screens, how to set the splash screen image and how to change the background color.  Splash Screen Every Windows Store app must have splash screen. Splash screen consists of image and a background color. Whenever the user will launch application, splash screen will be the first to come up. Now you might be thinking, what is the purpose of splash screen??? We all know that, whenever any application is launched, lot many things happened at backend before our application is fully launched. So, splash screen provides a way to hide all those background details from the user. This splash screen is launched, when application is initialized and as soon as our application is ready for interaction, this splash screen goes off. Isn't it a nice thing ? Now question is can we customize this splash screen ? Then my answer will be Yes. You can customize image as well as background color. Enough of th