controltemplate

WPF ControlTemplates must have TargetType or not?

对着背影说爱祢 提交于 2019-12-01 03:16:37
Do ControlTemplates in WPF require a TargetType? I am restyling some controls, and notice that the comboboxitem, listiviewitem and listboxitem all have the same template: <ControlTemplate x:Key="ListBoxItemCT" TargetType="{x:Type ListBoxItem}"> <Border x:Name="Bd" SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" CornerRadius="1"> <ContentPresenter x:Name="cpItemContent" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"

How to access the elements of a ControlTemplate in Xamarin Forms

自闭症网瘾萝莉.ら 提交于 2019-12-01 02:29:57
问题 I have a ControlTemplate defined in App.xaml. Now, I need to be able to handle certain UI events. In Visual Studio's XAML editor, if I attach a handler to an event, the handler is created in App.xaml.cs. However, I need to do this in pages that use this control template. I'm thinking the only way is to iterate through the elements in the control template and find the right element and create handlers in pages. However, I'm not sure how to access the elements from the ControlTemplate object.

How to Inherit a Control Template

戏子无情 提交于 2019-12-01 02:26:40
I working on a WPF project where I've over-ridden the CheckBox control for some special operations. That is working correctly. My problem is that the ControlTemplate that was applied from the theme (shinyred.xaml from codeplex), is not applied to my over-ridden control. Is there a way to inherit the CheckBox ControlTemplate for use by my new control? All the samples the I can find are focused on inheriting the style for the CheckBox , but nothing about the ControlTemplate . No, as you said it is possible to 'inherit' a style by using the BasedOn property, but it's not possible to directly

How to apply TextBox Control Template?

不想你离开。 提交于 2019-11-30 23:21:06
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="150" /> </Grid> (Code Listing 1) And that yields something looking like this... (Figure 1) As you can

WPF Validation Control Template overlapping

自古美人都是妖i 提交于 2019-11-30 22:52:27
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 ValidationIcon}, Converter={StaticResource UriConverter}}" Margin="1" RenderOptions.BitmapScalingMode=

How to Inherit a Control Template

空扰寡人 提交于 2019-11-30 22:42:00
问题 I working on a WPF project where I've over-ridden the CheckBox control for some special operations. That is working correctly. My problem is that the ControlTemplate that was applied from the theme (shinyred.xaml from codeplex), is not applied to my over-ridden control. Is there a way to inherit the CheckBox ControlTemplate for use by my new control? All the samples the I can find are focused on inheriting the style for the CheckBox , but nothing about the ControlTemplate . 回答1: No, as you

Binding custom dependency property to custom WPF style

依然范特西╮ 提交于 2019-11-30 20:04:29
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 Property="HorizontalContentAlignment" Value="Stretch"/> <Setter Property="VerticalContentAlignment"

Default ControlTemplate for CheckBox

ⅰ亾dé卋堺 提交于 2019-11-30 17:35:23
问题 I can't find the default WPF ControlTemplate for a CheckBox . Does anyone know how to locate it? All I can find is the SilverLight default checkbox template on MSDN. MSDN has a custom control template for the WPF checkbox example which uses X's instead of check marks. I'm specifically looking for the default check mark style that comes standard with WPF - I just can't locate the XAML for it. I've also tried saving the template using XamlWriter to no avail. Downloading the Simple Styles

WPF - Bind UserControl visibility to a property

人走茶凉 提交于 2019-11-30 17:29:46
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> </ControlTemplate> I would like to bind Visibility of ActivityIndicatorControl to a property, let's

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

橙三吉。 提交于 2019-11-30 17:07:53
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"> <Setter Property="Background" TargetName="ButtonBorder" Value="LightGray" /> </Trigger> <Trigger Property=