Directory Freebies VS CheatSheet Forum

RSS

Email

Translate

Home About Archive Privacy Contact Advertise Write for Dev102

Hi

 

While working on a complex UI application in WPF I noticed that because I was using DataTemplates both the Xaml and the Code Behind got very messy, that is because if you need to implement some events in the code behind you basically “mix” code from the template and code from the Window, plus you cannot access the elements in the template from the code behind.

Let’s look at the following example:


Continue Reading...
Posted by Shahar Y on Aug 7th, 2008 | Filed under .Net, WPF | 17 Comments

Usually, the WPF controls are declared in the .xaml file and not in the code behind (.xaml.cs file). However, we might need to use some of those controls in the code behind in order to manipulate them. How can we get the handle of such a control if it “resides” in the xaml file? Take a look at the following xaml code:

<Window x:Class="WpfApplication2.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300" MouseLeftButtonDown="window_Clicked">
    <Grid>
        <TextBlock x:Name="fullNameControl" FontSize="20"
                   Text="{Binding Path=FullName}">
        </TextBlock>
    </Grid>
</Window>

There is a TextBlock called fullNameControl, in the code behind I change its background color to gold when the window is clicked:


Continue Reading...

SVG (Scalable Vector Graphics) is an open W3C standard for graphics file format and Web development language based on XML. Those image are made up of lines, curves and other “smooth” elements so when you zoom in on a SVG it stays smooth (unlike GIF, JPEG, PNG). 

Imagine you can draw some of your user interface elements in a vector drawing application like: Adobe,   InkScape (free) or Skencil (free) and convert your work into WPF XAML or Silverlight XAML. ViewerSVG  (SVG to xaml converter) is your tool.

image


Continue Reading...
Posted by Shahar A on May 27th, 2008 | Filed under C#, WPF | 5 Comments

Master-Detail is a pattern for displaying details of a specific item selected from a list of items. In this post I’ll demonstrate how to use master-detail in WPF with two levels of objects, each displayed in a ComboBox and Data Binding to tie them together.


Continue Reading...
Posted by Shahar Y on Apr 23rd, 2008 | Filed under .Net, WPF | 4 Comments

DataTemplates are a great feature introduced in WPF, it allows to determine how data is presented and how data binding accesses the presented data. Just as we can apply a visual style to a specific UI control, we can do it for a specific data type. There is just one problem here, DataTemplates are good [...]


Continue Reading...
Posted by Amit on Apr 17th, 2008 | Filed under Visual Studio | 38 Comments

This is a list of 10 great shortcuts me and my co workers use frequently, we thought you all should know too. Here they are:

CTRL + ".": This is actually a shortcut for a shortcut. it is the same as CTRL + SHIFT + F10 which opens the smart tag window and allows you to [...]


Continue Reading...

Hi.
Ever had the following error in Visual Studio:error CS0103: The name ‘InitializeComponent’ does not exist in the current context.I sure did…
There’s a very specific reason for this and it’s in the project settingsThis usually happens whenever you try to add a WPF control/window to a .NET 2.0 Class library or project. The reason for this [...]


Continue Reading...
Posted by Amit on Jan 5th, 2008 | Filed under .Net, C#, Visual Studio, WPF | 1 Comment

Hi all.
First of all Let me give credit to Shahar A. for showing me this.
As it turns out, my latest post about DataTemplates was not the most efficient way to do this.
I used a different Template for the root and a second one for the all the rest of the data.
What i learned is that [...]


Continue Reading...
Posted by Amit on Dec 27th, 2007 | Filed under .Net, C#, Visual Studio, WPF | 3 Comments

Hi all.
I am going to show you a simple example of how to use Hierarchical DataTemplates in a tree view for an easy display of hierarchical Data.
The Example shows the links in a WebPage recursively.
First we will create the data model that we want to show, note that we have two separate models, one [...]


Continue Reading...
Posted by Amit on Dec 22nd, 2007 | Filed under .Net, C#, Utilities, WPF | 8 Comments

Hi all.
Say you absolutely have to change the Button of a Combobox to a circle instead of an arrow - you just have to!!!!
Here comes Microsoft Expression Blend to the rescue, If you code in WPF and don’t have it yet, you can get it here, Its the beta of blend 2 but believe [...]


Continue Reading...
Write Article for Dev102

Write for Dev102!

We pay for user submitted tutorials and articles that we publish. Anyone can send in a contribution

Learn More