templatebinding

Setting Border background with a template binding

我的未来我决定 提交于 2019-12-21 14:58:12
问题 Value="{TemplateBinding HeaderColor}"I've created my own control, and I'm wondering if I can bind a Border.Background to a template property. Currently i'm setting it with a StaticResource like the following: <Color x:Key="ControlMouseOverColor">green</Color> <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="headerLayout"> <EasingColorKeyFrame KeyTime="0:0:6" Value="{StaticResource

WPF Custom Control: TemplateBinding to Image

▼魔方 西西 提交于 2019-12-21 11:14:23
问题 I am creating a WPF custom control, a Button with an Image and Text . I have added two dependency properties to the control, ImagePath and Text , and the control template (in Themes\Generic.xaml) is a simple stack panel that arranges the image and text horizontally. The Text property works fine. But for some reason, the sample image in my test project doesn't appear when I use TemplateBinding to the ImagePath dependency property to get its path. I have tested the image by temporarily

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

时间秒杀一切 提交于 2019-12-18 14:49:32
问题 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),

TemplateBinding does not work in certain cases(when using TranslateTransform)

荒凉一梦 提交于 2019-12-13 12:05:48
问题 This is how I reproduced this problem in WPF: Create a custom control: public class TestCustomControl : Control { static TestCustomControl() { DefaultStyleKeyProperty.OverrideMetadata(typeof(TestCustomControl), new FrameworkPropertyMetadata(typeof(TestCustomControl))); } public string Text { get { return (string)GetValue(TextProperty); } set { SetValue(TextProperty, value); } } // Using a DependencyProperty as the backing store for Text. This enables animation, styling, binding, etc... public

Binding to AlternationCount of ItemsControl from ItemTemplate of a nested ItemsControl

こ雲淡風輕ζ 提交于 2019-12-13 05:24:41
问题 I have an ItemsControl nested in the DataTemplate of another ItemsControl. This seemed like the easiest way to display a grid of numbers from a two-dimensional array, which it did very nicely. The problem I have is that I want to change the color a particular number in the grid. I was hoping to trigger off the AlternationIndex of both ItemsControls, so I can identify exactly which number to highlight. In the DataContext for the parent ItemsControl I have a 2-D array of integers like this:

angular2 property contains dom in template binding

我是研究僧i 提交于 2019-12-13 04:38:13
问题 I'm trying to displaying data from wordpress site in angular2 app, the wordpress post's content can contain DOM elements, but I want to render it instead of displaying it as a text. I'm using rest API V2 plugin to get the posts from wordpress. Home.ts import {Component, NgFor} from 'angular2/angular2'; import {Http, HTTP_PROVIDERS} from 'angular2/http'; import {RouterLink, ROUTER_DIRECTIVES, RouteConfig} from 'angular2/router'; @Component({ selector: 'home', viewProviders: [HTTP_PROVIDERS],

How to make a WPF resource be recalculated when a trigger's run?

狂风中的少年 提交于 2019-12-10 19:35:49
问题 In short: I've got a Style . It uses TemplateBinding a fair bit to make it parametrized instead of repeating myself over and over again. However, when a trigger for that style gets used and a resource gets used in a setter in that trigger, it just doesn't show up! Not even the default value gets shown. Here's a small program that replicates this issue: TestDictionary.xaml <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft

ListViewItem with CheckBox IsChecked Binding to ViewModel

泪湿孤枕 提交于 2019-12-07 18:59:32
问题 I have a ListView with a DataTemplate for displaying for each ListViewItem a Checkbox. <ListView ItemsSource="{Binding TableNames}"> <ListView.ItemTemplate> <DataTemplate> <CheckBox Content="{Binding}" IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsSelected, Mode=TwoWay}" /> </DataTemplate> </ListView.ItemTemplate> </ListView> The ItemsSource ("TableNames") is deklared in the ViewModel like this: private ObservableCollection<Item> _TableNames = new

TemplateBinding not working for textbox text

泪湿孤枕 提交于 2019-12-07 05:17:20
问题 I have a custom control called EnhancedTextBox which is a UserControl that has a TextBox and a Button . To the consumer I want it to mostly look like a TextBox, so I did the following: <UserControl.Template> <ControlTemplate TargetType="textBoxes:EnhancedTextBox"> ... <TextBox Text="{TemplateBinding Text}"... And in EnhancedTextBox I have public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof (String), typeof (EnhancedTextBox)); public String Text

TemplateBinding from a Style DataTrigger In ControlTemplate

[亡魂溺海] 提交于 2019-12-07 02:28:47
问题 In the following XAML I'm using a Rectangle with a Border as the Template for a ToggleButton. I want the BorderBrush to be a different colour to reflect the changing value of ToggleButton.IsChecked. Unfortunately my attempt here of using a TemplateBinding in the DataTrigger doesn't work. What do I need to do instead? <StackPanel Orientation="Horizontal"> <StackPanel.Resources> <ControlTemplate x:Key="ButtonAsSwatchTemplate"> <Border BorderThickness="1"> <Border.Style> <Style> <Setter Property