controltemplate

How to conditionally insert a Checkbox in a list item of a customized ListView when using class inheritance?

回眸只為那壹抹淺笑 提交于 2019-12-12 04:24:45
问题 I try to make a customized ListView which fills each list item with some stuff and an initial Checkbox if the concrete inheriting class wishes so. Currently no Checkbox is displayed so I guess my code of the ContentControl stuff is somehow erroneous. <UserControl x:Class="local:MyListView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="some/path/here"> <ListView> <ListView.View> <GridView> <GridViewColumn>

Configurable HeaderTemplate

不羁岁月 提交于 2019-12-12 03:09:35
问题 I have about 12 Expanders that need to have a custom HeaderTemplate . The HeaderTemplate has a textblock to display the header text, along with a button. The button has a custom control template so that I can display the button as a Path within a VisualBrush . <Expander VerticalAlignment="Top" Header="Fields" IsExpanded="True"> <Expander.HeaderTemplate> <DataTemplate> <DockPanel LastChildFill="False"> <TextBlock VerticalAlignment="Center" DockPanel.Dock="Left" FontSize="14" Foreground="

Acces Textblock Text inside a ButtonStyle from codebehind

▼魔方 西西 提交于 2019-12-12 02:48:50
问题 How to access the tbRegistrationBtn.text property from code behind from a custom made style? My button is being created dynamically from codebehind and gets added to the parent control (stackpanel): The button gets created when i press a other button on my screen. Codebehind: Button newBtn = new Button(); newBtn.Width = 160; newBtn.Height = 46; newBtn.Style = this.FindResource("ButtonStyleRegistration") as Style; spHorizontal.Children.Add(newBtn); Xaml: <Style x:Key="ButtonStyleRegistration"

Accessing ProgressBar within ControlTemplate of Button

若如初见. 提交于 2019-12-12 00:59:45
问题 I am wondering how to access my progressbar within a button. The control template used by the button is: <ControlTemplate x:Key="ButtonWithProgressBarControlTemplate" TargetType="{x:Type Button}"> <Grid OpacityMask="Black"> <Rectangle x:Name="rectangle" Fill= "{TemplateBinding Background}" RadiusX="8" RadiusY="8" Margin="0,0,0,0" OpacityMask="Black"> <Rectangle.Effect> <DropShadowEffect ShadowDepth="2" /> </Rectangle.Effect> </Rectangle> <ContentPresenter x:Name="contentPresenter" Content="

How to make my custom UserControl handle a two-way Binding when it is inside a Template Setter inside a DataTrigger?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 16:42:54
问题 If I put the TimeSpanPicker directly in the UserControl element, it works. If I put a DateTimePicker (from the Extended WPF Toolkit) instead of my TimeSpanPicker, it works in both ways. (This situation is what I wish to use, it is in the code below) If I put the TimeSpanPicker in a Template Setter inside a DataTrigger inside Style.Triggers inside UserControl.Style, the Binding stops working. The binding that does not work in any way (although it is set to TwoWay) is this: TimeSpan="{Binding

Altering a ControlTemplate from code behind

▼魔方 西西 提交于 2019-12-11 13:56:00
问题 Application: Hello, I am dynamically adding custom controls to a WPF application. The control is a custom slider. I have created a ControlTemplate in the XAML file which I want to use as the template for these dynamically created controls. I am currently applying the template by using: newControl.Template = (ControlTemplate)parent.Resources["nameOfTheControlTemplate"]; This currently works OK (i.e. compiles, runs, and applys the template). The template looks like this: ( Sorry for wall of

WPF TabControl ControlTemplate

一笑奈何 提交于 2019-12-11 12:37:52
问题 I'm looking to create a new control template for a WPF tabcontrol. The situation I have is that there will be a number of tabs in the control and the user will be able to add and delete these tabs. Ideally I would like to create something along the lines of the Firefox / IE tabs whereby you have a delete button inside the tab heading to delete the current tab. Also, and slightly more complicated, I want to have a new tab button that is always on the right hand side of the last tab in the

ToggleButton Style only works on last ToggleButton

旧巷老猫 提交于 2019-12-11 11:14:48
问题 I'm trying to customize my ToggleButtons so that when checked they say 'Yes' in green and when not checked, say 'No' in red. I've created the following style which is sitting in my Styles resource dictionary. <!-- ToggleButtons --> <Style x:Key="YesNoToggleStyle" TargetType="ToggleButton"> <Style.Triggers> <Trigger Property="IsChecked" Value="True"> <Setter Property="Background" Value="SpringGreen" /> <Setter Property="Content"> <Setter.Value> <TextBlock Text="Yes"/> </Setter.Value> </Setter>

Both 'ItemTemplate' and 'ItemTemplateSelector' are set; 'ItemTemplateSelector' will be ignored

别来无恙 提交于 2019-12-11 07:16:07
问题 Following this question, I have another question about TreeView . What I already have is a TreeView with HierarchicalDataTemplate , in which I can change the HierarchicalDataTemplate of level2 (like explained in the question and the answer). What I want now, is to change the look of the expander of the Treeview . For this, I have defined a ControlTemplate named ctForTreeViewItem , and I use it like this: <Window.Resources> <ControlTemplate x:Key="ctForTreeViewItem" TargetType="{x:Type

Problem reading AttachedProperty in ControlTemplate

早过忘川 提交于 2019-12-11 06:51:57
问题 This is my attached property: public class MyButtonThing { public static string GetText2(DependencyObject obj) { return (string)obj.GetValue(Text2Property); } public static void SetText2(DependencyObject obj, string value) { obj.SetValue(Text2Property, value); } public static readonly DependencyProperty Text2Property = DependencyProperty.RegisterAttached("Text2", typeof(string), typeof(System.Windows.Controls.Button)); } This is my ControlTemplate: EDIT this will work fine: <Window.Resources>