controltemplate

How can I set a property of a DropShadowEffect via a Trigger in a ControlTemplate?

风格不统一 提交于 2019-11-30 16:27:31
问题 I have a Button ControlTemplate and I'm trying to modify a DropShadowEffect on a Border by using a Trigger . Here is my Xaml: <Button.Template> <ControlTemplate TargetType="Button"> <Border x:Name="ButtonBorder" Margin="10" CornerRadius="5" Background="Gray"> <Border.Effect> <DropShadowEffect ShadowDepth="5" x:Name="BorderEffect" /> </Border.Effect> <ContentPresenter HorizontalAlignment="Center" /> </Border> <ControlTemplate.Triggers> <Trigger Property="Button.IsMouseOver" Value="True">

How to place a ScrollViewer on top of the content it should scroll

半腔热情 提交于 2019-11-30 13:13:17
I would like to put my ScrollViewer in such a way that it overlaps/sits on top of the content it scrolls. I would set the Opacity of the ScrollViewer so that the content is visible underneath. As far as I understand the default ScrollViewer, this doesn't seem to be possible out of the box since the content is nested inside the ScrollViewer. Any ideas on how to make this work? EDIT: I understand that the ScrollViewer is a Decorator and that the content is not aware of the ScrollViewer. This separation is good and I don't want the content to be aware of the ScrollViewer. What I try to do is a

WPF ControlTemplate vs UserControl

家住魔仙堡 提交于 2019-11-30 10:26:42
问题 I've recently made an UserControl , which took quite a long time, because I had to work with custom Dependency Properties and so on... Anyways, it was just a bunch of 3 controls: TextBox, Popup with Hierarchical Tree. Now I realized I could probably write a ControlTemplate only. Hence what is the benefit of using UserControl ? 回答1: There are three cases to consider here: UserControl, ControlTemplate, and custom Control. (I'm guessing a DataTemplate needs no explanation) A custom Control is

Can WPF themes be used to include multiple skins for an application that can be changed at runtime?

时光毁灭记忆、已成空白 提交于 2019-11-30 09:11:00
WPF allows a control library to provide different resource dictionaries for different system themes, essentially allowing an application to match the operating system's selected visual theme (Aero, Luna, etc). I'm wondering if I can include multiple theme resource dictionaries with my application and utilise some existing theme support within the framework. This should work for my own theme names, and ideally allow the user to change the theme and therefore the skinned appearance of the application at runtime. Even if this were only a config setting, it could still be interesting. Here is a

Binding custom dependency property to custom WPF style

血红的双手。 提交于 2019-11-30 04:57:55
问题 I have an issue when designing a inherited Expander. My intention is to have a progress bar behind the toggle button and text in the default Expander header. I have this XAML code which gives me the progress bar in the header. It is a custom style. <Style x:Key="CurrentScanExpanderStyle" TargetType="{x:Type local:ProgressExpander}"> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/> <Setter Property="Background" Value="Transparent"/> <Setter

PasswordBox does not assume style

北城以北 提交于 2019-11-30 03:34:59
问题 I have the following style definitions: <!-- Border --> <Style x:Key="MyControlBorder" TargetType="{x:Type Border}"> <Setter Property="BorderBrush" Value="DarkKhaki" /> <Setter Property="Background" Value="White" /> <Setter Property="BorderThickness" Value="1" /> <Setter Property="CornerRadius" Value="10" /> </Style> <!-- TextBox --> <Style x:Key="MyTextBox" TargetType="{x:Type TextBox}"> <Setter Property="Height" Value="30" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate

WPF ControlTemplate vs UserControl

ぐ巨炮叔叔 提交于 2019-11-29 20:46:37
I've recently made an UserControl , which took quite a long time, because I had to work with custom Dependency Properties and so on... Anyways, it was just a bunch of 3 controls: TextBox, Popup with Hierarchical Tree. Now I realized I could probably write a ControlTemplate only. Hence what is the benefit of using UserControl ? There are three cases to consider here: UserControl, ControlTemplate, and custom Control. (I'm guessing a DataTemplate needs no explanation) A custom Control is something you provide when you create base functionality of a new UI component. There are various pros and

How to place a ScrollViewer on top of the content it should scroll

混江龙づ霸主 提交于 2019-11-29 18:53:06
问题 I would like to put my ScrollViewer in such a way that it overlaps/sits on top of the content it scrolls. I would set the Opacity of the ScrollViewer so that the content is visible underneath. As far as I understand the default ScrollViewer, this doesn't seem to be possible out of the box since the content is nested inside the ScrollViewer. Any ideas on how to make this work? EDIT: I understand that the ScrollViewer is a Decorator and that the content is not aware of the ScrollViewer. This

Can WPF themes be used to include multiple skins for an application that can be changed at runtime?

只愿长相守 提交于 2019-11-29 12:50:38
问题 WPF allows a control library to provide different resource dictionaries for different system themes, essentially allowing an application to match the operating system's selected visual theme (Aero, Luna, etc). I'm wondering if I can include multiple theme resource dictionaries with my application and utilise some existing theme support within the framework. This should work for my own theme names, and ideally allow the user to change the theme and therefore the skinned appearance of the

WPF ControlTemplate breaks style

强颜欢笑 提交于 2019-11-29 01:56:26
The stuff that does work I need to style controls of a certain type that are children of a StackPanel. I'm using: <StackPanel> <StackPanel.Resources> <Style TargetType="{x:Type TextBlock}">...</Style> </StackPanel.Resources> <TextBlock ...> ... </StackPanel> And this works fine! Each TextBlock looks to the resources of it's parent (the StackPanel) to find out how it should be styled. It doesn't matter how far down you nest the TextBlock down a StackPanel... if it doesn't find a style in its direct parent, it will look at its parent's parent and so on, until it finds something (in this case,