templatebinding

WPF Nested binding in a controltemplate

痴心易碎 提交于 2019-12-01 05:27:21
问题 I have successfully created a textbox that displays / collapses an error message depending upon a validation rule set in its model / vm. The code goes like this for the email for ex.: <StackPanel Grid.Row="3" Grid.Column="1"> <TextBox MaxLength="200" x:Name="mailTextBox" Style="{StaticResource SectionEditPropertyTextBox}" Text="{Binding Email, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" /> <ContentPresenter Visibility="{Binding ElementName=mailTextBox, Path=(Validation

How to use template binding inside data template in custom control (Silverlight)

爷,独闯天下 提交于 2019-11-30 11:38:56
I am trying to create control which will take ItemsSource and InnerTemplate and will show all the items wrapped in CheckBox es. The control has 2 dependency properties: public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register("ItemsSource", typeof(IEnumerable), typeof(CheckBoxWrapperList), null); public static readonly DependencyProperty InnerTemplateProperty = DependencyProperty.Register("InnerTemplate", typeof(DataTemplate), typeof(CheckBoxWrapperList), null); and here is the template: <ControlTemplate TargetType="local:CheckBoxWrapperList"> <Grid> <Grid

Can my WPF Style Setter use a TemplateBinding?

跟風遠走 提交于 2019-11-29 05:32:58
I'm trying to do something like this... <Style x:Key="MyBorderStyle" TargetType="Border"> <Setter Property="BorderBrush" Value="{StaticResource MyBorderBrush}" /> <Setter Property="Background" Value="{StaticResource MyBackgroundBrush}" /> <Setter Property="Padding" Value="{TemplateBinding Padding}" /> </Style> ...but I get the error: 'Padding' member is not valid because it does not have a qualifying type name. How do I provide a "qualifying type name"? Note: The reason I'm trying to do this, is that I'd like to include the same Border in a series of similar ControlTemplates. Thanks. EDIT:

WPF ControlTemplate: How to provide a default value for TemplateBinding?

对着背影说爱祢 提交于 2019-11-28 07:18:29
I am writing a WPF control that subclasses a Button. I then provide a default style in Themes\generic.xaml, that looks like this (simplified): <Style TargetType="{x:Type WPFControls:MyButton}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type WPFControls:MyButton}"> <Button x:Name="PART_Button" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" /> </ControlTemplate> </Setter.Value> </Setter> </Style> I would like the user to have the opportunity to change the control's background, but if he doesn't, I'd like to provide default

Can my WPF Style Setter use a TemplateBinding?

佐手、 提交于 2019-11-27 23:26:37
问题 I'm trying to do something like this... <Style x:Key="MyBorderStyle" TargetType="Border"> <Setter Property="BorderBrush" Value="{StaticResource MyBorderBrush}" /> <Setter Property="Background" Value="{StaticResource MyBackgroundBrush}" /> <Setter Property="Padding" Value="{TemplateBinding Padding}" /> </Style> ...but I get the error: 'Padding' member is not valid because it does not have a qualifying type name. How do I provide a "qualifying type name"? Note: The reason I'm trying to do this,

In WPF, why doesn't TemplateBinding work where Binding does?

孤人 提交于 2019-11-27 04:44:21
Ok... this is leaving me scratching my head. I have two WPF controls--one's a user control and the other's a custom control. Let's call them UserFoo and CustomFoo. In the control template for CustomFoo, I use an instance of UserFoo which is a named part so I can get to it after the template is applied. That works fine. Now both UserFoo and CustomFoo have a Text property defined on them (independently, i.e. not a shared DP using AddOwner. Don't ask...) that are both declared like this... public static readonly DependencyProperty TextProperty = DependencyProperty.Register( "Text", typeof(string)

WPF ControlTemplate: How to provide a default value for TemplateBinding?

∥☆過路亽.° 提交于 2019-11-27 01:51:16
问题 I am writing a WPF control that subclasses a Button. I then provide a default style in Themes\generic.xaml, that looks like this (simplified): <Style TargetType="{x:Type WPFControls:MyButton}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type WPFControls:MyButton}"> <Button x:Name="PART_Button" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" /> </ControlTemplate> </Setter.Value> </Setter> </Style> I would like the user to

Template Binding in Control template

最后都变了- 提交于 2019-11-26 22:14:52
I have the following control template. I wish to set the source property for the image control in the control template using Template Binding. But since this is a control template for button control and the button control doesn't have source property, i can't use TemplateBinding in this case. <ControlTemplate x:Key="BtnTemplate" TargetType="Button"> <Border CornerRadius="5" Margin="15" Cursor="Hand"> <StackPanel> <Image Name="Img" Style="{StaticResource ImageStyle}" Source="temp.jpg" Height="100" Width="100" Margin="5"></Image> <Label Content="{TemplateBinding Content}" Background="Transparent

Template Binding with Attached Properties

限于喜欢 提交于 2019-11-26 14:27:15
问题 I have a standard style for my buttons but I want certain parts of the style to be configurable. e.g. I have a border appear when MouseOver is triggered for the button and I want the border colour to be configurable. Following this article: http://www.thomaslevesque.com/2011/10/01/wpf-creating-parameterized-styles-with-attached-properties/ I thought I could use attached properties and TemplateBinding to achieve this. I created the following attached property: public static class

In WPF, why doesn&#39;t TemplateBinding work where Binding does?

谁说我不能喝 提交于 2019-11-26 11:11:10
问题 Ok... this is leaving me scratching my head. I have two WPF controls--one\'s a user control and the other\'s a custom control. Let\'s call them UserFoo and CustomFoo. In the control template for CustomFoo, I use an instance of UserFoo which is a named part so I can get to it after the template is applied. That works fine. Now both UserFoo and CustomFoo have a Text property defined on them (independently, i.e. not a shared DP using AddOwner. Don\'t ask...) that are both declared like this...