controltemplate

WPF Validation Control Template overlapping

倖福魔咒の 提交于 2019-12-09 00:39:17
问题 I've got a user control with a control template to show validation errors, validation template: <ControlTemplate x:Key="TextBoxPropertyValidationTemplate"> <StackPanel> <Border BorderBrush="Red" BorderThickness="1"> <AdornedElementPlaceholder x:Name="MyAdorner" /> </Border> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Image Grid.Column="0" MaxHeight="16" MaxWidth="16" Source="{Binding Source={StaticResource

What does Binding=“{Binding (0)}” mean?

瘦欲@ 提交于 2019-12-08 16:38:09
问题 I found this: <DataTrigger Value="True" Binding="{Binding (0)}"> triggers in RibbonMenuButton template. What does it mean? I've tried to google, but found nothing. UPD more code: <ControlTemplate x:Key="RibbonMenuButtonControlTemplate1" TargetType="{x:Type RibbonMenuButton}"> ... <DataTrigger Binding="{Binding (0)}" Value="True"> <Setter Property="TextElement.Foreground" TargetName="MainGrid" Value="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}"/> <Setter Property="PathFill"

How to reuse Menu and Toolbar in different WPF UserControls with adding new buttons?

天涯浪子 提交于 2019-12-08 10:40:02
问题 I'm trying to port current WinForms app to WPF and need help with building WPF class structure. Currently in WinForms, I have one base class (with Menu, Toolbar, Grid and Context menu) and several inherited classes with different datasources and columns for the grid and additional buttons for menu, toolbar and context menu. Questions: What will be the best WPF class structure for my usercontrol to avoid inheritance? Can I move ToolBar into ResourceDictionary (e.g. ControlTemplate )? How to

How to change the color of the CheckMark in WPF CheckBox control?

╄→尐↘猪︶ㄣ 提交于 2019-12-08 05:38:12
问题 I have a custom template checkbox that I am implementing using a viewbox (using a viewbox to allow for simple scaling), and I can't figure out how to change out what is displayed when the checkbox is checked/unchecked. I would like for the checkmark to be red when checked (not the final look, just want to see it working). My Checkbox style: <Style x:Key="KioskCheckBox" TargetType="{x:Type CheckBox}"> <Setter Property="FontFamily" Value="{StaticResource FontFamilyLight}" /> <Setter Property=

Adding a custom dependency property to a Control Template in XAML

。_饼干妹妹 提交于 2019-12-07 12:15:03
问题 I have managed to get further with my read only check box after a bit of a break and now have the functionality I want in a reasonably elegant form. The problem is I have used a bit of a hack to make it work, although this is not a disaster it would be nice to do it better. To recap: I want a regular looking checkbox that does not self check when it is clicked, instead the click event triggers a background worker that later on causes a variable to be updated. This variable is bound to

Why is the ColorAnimation for Checked state not persisting color after the MouseOver state is triggered?

浪尽此生 提交于 2019-12-07 04:50:20
问题 I encountered an issue with a ControlTemplate for ToggleButton I created. When the button is Checked , a ColorAnimation is triggered and the control's background changes color. However, if the user enters the MouseOver state, another animation is triggered that affects the button's background as well. When the mouse is no longer in the MouseOver state, the control does not return to the color it should be while it is in the Checked state. I'm not sure why this does not persist when the

WPF - TemplateBinding doesn't recognize member content

蓝咒 提交于 2019-12-07 04:00:51
问题 Alright, so I have a window with the following resources <Window.Resources> <Style TargetType="Button"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <Grid> <TextBlock Text="{TemplateBinding Content}"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </Window.Resources> I am getting an error saying that, "The member "Content" is not recognized or is not accessible." What am I doing wrong? 回答1: You will have to define TargetType on ControlTemplate <ControlTemplate

When to use TemplateBinding and TemplatedParent in WPF

僤鯓⒐⒋嵵緔 提交于 2019-12-07 03:41:55
问题 I have a confusion over TemplateBinding and TemplatedParent. I have gone through this link also WPF TemplateBinding vs RelativeSource TemplatedParent But my doubt is when to use TemplateBinding and TemplatedParent? Thanks in advance. 回答1: {TemplateBinding X} is simply a shortcut way of writing the {Binding X, RelativeSource={RelativeSource TemplatedParent}} . They evaluate to the same thing, although TemplateBinding is evaluated at compile-time while RelativeSource TemplatedParent is

How to change control template from Style.Triggers

喜你入骨 提交于 2019-12-07 03:11:20
问题 I've done it this way: <Style x:Key="Button" BasedOn="{StaticResource LoginButton}" TargetType="Button"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <Grid> <Border CornerRadius="4"> <Border.Background> <LinearGradientBrush EndPoint="0,1"> <GradientStop Offset="0" Color="#0863a5" /> <GradientStop Offset="1" Color="#00457d" /> </LinearGradientBrush> </Border.Background> </Border> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/> <

Default ControlTemplate for Expander

梦想的初衷 提交于 2019-12-06 23:04:35
问题 can someone (probably using Blend) provide me a working default ControlTemplate for the WPF Expander? I want to do some slight modification but seems that I cannot find a source for a valid template. Thanks in advance. 回答1: I have blend, and can help you out. Here is what Blend generated for me. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style x:Key="ExpanderRightHeaderStyle" TargetType="{x