How to set an event function via a style?

Martin, you can assign an event handler directly from a style using an EventSetter: <Style TargetType=”{x:Type Button}”> <EventSetter Event=”Click” Handler=”SomeAction”/> </Style> @ColinE: I am not sure that using a style to perform event wire-up is a good idea. Styles, by definition, define the visual appearance of controls. Unfortunately, this seems to be a common and … Read more

XAML or C# code-behind

Creating an entire window in C# can be a mess of code. The best thing about WPF is that XAML allows you to separate your design from your logic, making for much easier-to-read code. I’ll use C# when I need to create dynamic controls, but I tend to keep my general design, static storyboards, styles, … Read more

how to access master page control from content page

In the MasterPage.cs file add the property of Label like this: public string ErrorMessage { get { return lblMessage.Text; } set { lblMessage.Text = value; } } On your aspx page, just below the Page Directive add this: <%@ Page Title=”” Language=”C#” MasterPageFile=”Master Path Name”….. %> <%@ MasterType VirtualPath=”Master Path Name” %> // Add this … Read more

How do I access an element of a control template from within code-behind

You need to get the template and locate the control by name on the templated control, something like: var template = MyList.Template; var myControl = (MyControl)template.FindName(“MyControlName”, MyList); Templates are just that: Abstract descriptions of what is to be created, the controls in templates only exist in the context of something that is being templated. Note … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)