Directory Freebies VS CheatSheet Forum

RSS

Email

Translate

Home About Archive Privacy Contact Advertise Write for Dev102
Posted by Shahar Y on Aug 7th, 2008 | Filed under .Net, WPF | 25 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...
Posted by Amit on Mar 17th, 2008 | Filed under ASP.Net | 9 Comments

As we all know whenever we build an ASP.NET application with a MasterPage, all the controls receive a prefix such as “ctl00$<ContentPlaceHolderID>$<NameYouGaveToControl>”  to their names according to their place in the page hierarchy. That is done in order to prevent from two controls to have the same ID on the same page.
We encounter a problem [...]


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