Click here to Skip to main content
15,896,111 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: XAML Power Toys 4.0 Released - Code Name MVVM Pin
Pete O'Hanlon10-Feb-09 11:38
mvePete O'Hanlon10-Feb-09 11:38 
QuestionWPF Best Practice Pin
mark_w_10-Feb-09 5:20
mark_w_10-Feb-09 5:20 
AnswerRe: WPF Best Practice Pin
Gideon Engelberth10-Feb-09 6:11
Gideon Engelberth10-Feb-09 6:11 
QuestionAdding images to the listboxitems in the WPF Listbox control Pin
Punjala9-Feb-09 23:12
Punjala9-Feb-09 23:12 
AnswerRe: Adding images to the listboxitems in the WPF Listbox control Pin
Pete O'Hanlon10-Feb-09 0:57
mvePete O'Hanlon10-Feb-09 0:57 
GeneralRe: Adding images to the listboxitems in the WPF Listbox control Pin
Punjala11-Feb-09 0:39
Punjala11-Feb-09 0:39 
GeneralRe: Adding images to the listboxitems in the WPF Listbox control Pin
Punjala11-Feb-09 4:03
Punjala11-Feb-09 4:03 
QuestionAccessing template member! Pin
AghaKhan8-Feb-09 7:25
AghaKhan8-Feb-09 7:25 
I have a template and would like to access a UIElement. Because it is a template, it is not an object unless it is a static object. How can I create a static object in a template? The x:Name=”someName” are only to access inside template NOT outside. So we get an error when we try to access from a class. i.e. in constructor I can’t access someName. This also means that I cannot write a function when there is a change.
How this can be done?
Best regards
Agha

<Button x:Class="WpfApplication1.DoubleCharBtn"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<Button.Template>
<ControlTemplate>
<Border x:Name="br" Background="Blue" CornerRadius="3" BorderBrush="Black">
<StackPanel Orientation="Vertical">
<TextBlock x:Name="TextUpperChar" HorizontalAlignment="Center" Text="{Binding UpperLetter}" />
<TextBlock x:Name="TextLowerChar" HorizontalAlignment="Center" Text="{Binding LowerLetter}" />
</StackPanel>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Button.IsPressed" Value="True">
<Setter TargetName="br" Property="Background" Value="Red"/>
<Setter TargetName="TextUpperChar" Property="Background">
<Setter.Value>
<LinearGradientBrush>
<GradientStop Offset="1" Color="DarkBlue"/>
<GradientStop Offset="0.5" Color="Blue"/>
<GradientStop Offset="0" Color="DarkBlue"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>

</Button>

namespace WpfApplication1
{
/// <summary>
/// Interaction logic for DoubleCharBtn.xaml
/// </summary>
public partial class DoubleCharBtn : Button
{

internal static readonly DependencyProperty UpperCharProperty =
DependencyProperty.Register(
"UpperChar",
typeof(char),
typeof(DoubleCharBtn),
new FrameworkPropertyMetadata(' ', FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender, UpperCharChanged));


public static void UpperCharChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
char TempChar = (char)e.NewValue;
DoubleCharBtn doubleCharBtn = (DoubleCharBtn)d;
// doubleCharBtn.TextUpperChar.Text = string.Format("{0}",TempChar);

}

public char UpperChar
{
set { SetValue(UpperCharProperty, value); }
get { return (char)GetValue(UpperCharProperty); }
}

internal static readonly DependencyProperty LowerCharProperty =
DependencyProperty.Register(
"LowerChar",
typeof(char),
typeof(DoubleCharBtn),
new FrameworkPropertyMetadata(' ', FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender, LowerCharChanged));


public static void LowerCharChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
char TempChar = (char)e.NewValue;
DoubleCharBtn doubleCharBtn = (DoubleCharBtn)d;
// doubleCharBtn.TextLowerChar.Text = string.Format("{0}", TempChar);
}

public char LowerChar
{
set { SetValue(LowerCharProperty, value); }
get { return (char)GetValue(LowerCharProperty); }
}

public DoubleCharBtn()
{
InitializeComponent();
}
}
}
AnswerRe: Accessing template member! Pin
ABitSmart12-Feb-09 17:14
ABitSmart12-Feb-09 17:14 
QuestionHow to attach WPF controls when maximaize the window ? Pin
Yanshof7-Feb-09 8:29
Yanshof7-Feb-09 8:29 
AnswerRe: How to attach WPF controls when maximaize the window ? Pin
Leung Yat Chun8-Feb-09 0:31
Leung Yat Chun8-Feb-09 0:31 
QuestionLaunch Silverlight app in an internal browser of VS2008 ? Pin
WolveFred26-Feb-09 5:44
WolveFred26-Feb-09 5:44 
AnswerRe: Launch Silverlight app in an internal browser of VS2008 ? Pin
Mark Salsbery6-Feb-09 10:28
Mark Salsbery6-Feb-09 10:28 
AnswerRe: Launch Silverlight app in an internal browser of VS2008 ? Pin
Michael Sync8-Feb-09 6:39
Michael Sync8-Feb-09 6:39 
GeneralRe: Launch Silverlight app in an internal browser of VS2008 ? Pin
WolveFred214-Apr-09 3:49
WolveFred214-Apr-09 3:49 
QuestionSilverlight images not appearing in Firefox (solved) Pin
Kevin McFarlane6-Feb-09 4:38
Kevin McFarlane6-Feb-09 4:38 
AnswerRe: Silverlight images not appearing in Firefox Pin
Michael Sync8-Feb-09 6:38
Michael Sync8-Feb-09 6:38 
GeneralRe: Silverlight images not appearing in Firefox Pin
Kevin McFarlane8-Feb-09 7:17
Kevin McFarlane8-Feb-09 7:17 
GeneralRe: Silverlight images not appearing in Firefox Pin
Michael Sync8-Feb-09 7:20
Michael Sync8-Feb-09 7:20 
QuestionHow to generate items inside a Panel using WPF DataBinding? Pin
Moim Hossain6-Feb-09 2:39
Moim Hossain6-Feb-09 2:39 
AnswerRe: How to generate items inside a Panel using WPF DataBinding? Pin
Pete O'Hanlon6-Feb-09 2:56
mvePete O'Hanlon6-Feb-09 2:56 
GeneralRe: How to generate items inside a Panel using WPF DataBinding? Pin
Moim Hossain6-Feb-09 3:01
Moim Hossain6-Feb-09 3:01 
QuestionForms Authentication Pin
VisualLive5-Feb-09 21:20
VisualLive5-Feb-09 21:20 
AnswerRe: Forms Authentication Pin
Pete O'Hanlon5-Feb-09 22:37
mvePete O'Hanlon5-Feb-09 22:37 
GeneralRe: Forms Authentication Pin
VisualLive5-Feb-09 23:36
VisualLive5-Feb-09 23:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.