controltemplate

RectangleGeometry with relative dimensions… how?

↘锁芯ラ 提交于 2019-12-19 17:00:03
问题 I'm trying to replicate the nowadays so fashionable "reflex" effect on a controltemplate for buttons I'm creating. The basic idea is to create a rectangle with a gradient fill from white to transparent and then clip some of that semi-transparent rectangle with a rectanglegeometry. The problem is that I don't know how to define a relative rectangle geometry. I kind of worked around width by defining a large value (1000), but height is a problem. For example, it works good for buttons that have

RectangleGeometry with relative dimensions… how?

限于喜欢 提交于 2019-12-19 16:59:14
问题 I'm trying to replicate the nowadays so fashionable "reflex" effect on a controltemplate for buttons I'm creating. The basic idea is to create a rectangle with a gradient fill from white to transparent and then clip some of that semi-transparent rectangle with a rectanglegeometry. The problem is that I don't know how to define a relative rectangle geometry. I kind of worked around width by defining a large value (1000), but height is a problem. For example, it works good for buttons that have

RectangleGeometry with relative dimensions… how?

醉酒当歌 提交于 2019-12-19 16:59:10
问题 I'm trying to replicate the nowadays so fashionable "reflex" effect on a controltemplate for buttons I'm creating. The basic idea is to create a rectangle with a gradient fill from white to transparent and then clip some of that semi-transparent rectangle with a rectanglegeometry. The problem is that I don't know how to define a relative rectangle geometry. I kind of worked around width by defining a large value (1000), but height is a problem. For example, it works good for buttons that have

When overriding WPF templates do I have to override each theme's template separately?

我只是一个虾纸丫 提交于 2019-12-19 08:49:09
问题 I have a requirement to change a very small part of the WPF ComboBox's template. If I take a copy of the existing template for the Luna theme and make the change it all works fine initially. But if the user has a different theme, my ComboBox retains it's custom theme, (Which is obviously based on Luna) so looks out of place. Is there any way of overriding just parts of a template so the majority of the template still respects the windows theme? I notice that parts of the template define an

Define a WPF ControlTemplate at runtime

♀尐吖头ヾ 提交于 2019-12-19 07:59:49
问题 I would like to define a ControlTemplate at runtime. Is this possible? I have noticed the VisualTree property on the ControlTemplate class. I have also noticed that it uses the FrameworkElementFactory class. However, I cannot seem to get it to work. Is it possible to create a ControlTemplate at runtime? 回答1: Yes, you can do this using FrameworkElementFactory. Charles Petzold has a walkthrough of this in chapter 11 of "Applications = Code + Markup," but the basic idea is that you create a

Define a WPF ControlTemplate at runtime

被刻印的时光 ゝ 提交于 2019-12-19 07:59:07
问题 I would like to define a ControlTemplate at runtime. Is this possible? I have noticed the VisualTree property on the ControlTemplate class. I have also noticed that it uses the FrameworkElementFactory class. However, I cannot seem to get it to work. Is it possible to create a ControlTemplate at runtime? 回答1: Yes, you can do this using FrameworkElementFactory. Charles Petzold has a walkthrough of this in chapter 11 of "Applications = Code + Markup," but the basic idea is that you create a

How to apply TextBox Control Template?

≯℡__Kan透↙ 提交于 2019-12-19 03:56:10
问题 I'm trying to simplify some code and improve my maintainability. I was initially seeking a way to have a text box aligned to the left, that can shrink and expand to a maximum value without centering inside a grid cell after reaching the maximum value. So I started out writing some code like this... <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="200" /> </Grid.ColumnDefinitions> <TextBox Text="Some text" VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="10" MaxWidth=

WPF - Bind UserControl visibility to a property

我怕爱的太早我们不能终老 提交于 2019-12-18 18:54:19
问题 I have a ListView bound to ObservableCollection. Data are loaded from the internet and then added to collection. The download takes few seconds and I want to indicate user that the data is loading. I created an UserControl that indicates activity. I placed it inside of ControlTemplate. <ControlTemplate x:Key="ListViewControlTemplate1" TargetType="{x:Type ListView}"> <Grid> <local:ActivityIndicatorControl HorizontalAlignment="Center" Height="Auto" Margin="0" VerticalAlignment="Center"/> </Grid

Achieve “slide down” animation in WPF

你说的曾经没有我的故事 提交于 2019-12-18 02:42:31
问题 I am attempting to create my own template for an Expander control. When the control is expanded, I want the content to slide down slowly. The desired height of the content is not known at compile time. I thought we could define the slide down as an animation: <Storyboard x:Key="ExpandContent"> <DoubleAnimation Storyboard.TargetName="_expanderContent" Storyboard.TargetProperty="Height" From="0.0" To="{Binding ElementName=_expanderContent,Path=DesiredHeight}" Duration="0:0:1.0" /> </Storyboard>

Achieve “slide down” animation in WPF

橙三吉。 提交于 2019-12-18 02:42:30
问题 I am attempting to create my own template for an Expander control. When the control is expanded, I want the content to slide down slowly. The desired height of the content is not known at compile time. I thought we could define the slide down as an animation: <Storyboard x:Key="ExpandContent"> <DoubleAnimation Storyboard.TargetName="_expanderContent" Storyboard.TargetProperty="Height" From="0.0" To="{Binding ElementName=_expanderContent,Path=DesiredHeight}" Duration="0:0:1.0" /> </Storyboard>