controltemplate

How to access a child control's property when it is declared in a ControlTemplate?

自作多情 提交于 2021-02-16 15:20:23
问题 I have a GridView in which I want to embed a checkbox into the header of one of the columns. I need to check it's IsChecked property in code-behind. However, I cannot access it by name as it is in a template for the column header like below: <ListView.View> <GridView> <GridViewColumn> <GridViewColumn.HeaderContainerStyle> <Style TargetType="{x:Type GridViewColumnHeader}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type GridViewColumnHeader}" > <Border

recursive menu item with default template and itemTemplate

核能气质少年 提交于 2021-02-07 12:54:43
问题 I have a WPF Control template for the MenuItem type: <Style TargetType="{x:Type MenuItem}"> <Setter Property="Background" Value="Transparent" /> <Setter Property="Cursor" Value="Hand" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type MenuItem}"> <Border Background="{TemplateBinding Background}"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions>

How to conditionally insert a Checkbox in a list item of a customized ListView?

痞子三分冷 提交于 2020-02-07 23:49:05
问题 I try to make a customized ListView which fills each list item with some stuff and an initial Checkbox if desired. Currently no Checkbox is displayed so I guess my code of the ContentControl stuff is somehow erroneous. <ListView xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ListView.View> <GridView> <GridViewColumn> <GridViewColumn.CellTemplate> <DataTemplate> <!-- Each list item: [Checkbox] Label --> <StackPanel

WPF - ListView Item on Selected change Font size

旧城冷巷雨未停 提交于 2020-01-24 11:24:31
问题 this is my code: <Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <ListBox ItemsSource="{Binding Persons}"> <ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <Border Background="White" BorderThickness="5" Name="Bd"> <Border.Style> <Style TargetType=

WPF - ListView Item on Selected change Font size

情到浓时终转凉″ 提交于 2020-01-24 11:23:47
问题 this is my code: <Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <ListBox ItemsSource="{Binding Persons}"> <ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <Border Background="White" BorderThickness="5" Name="Bd"> <Border.Style> <Style TargetType=

Binding selectedItem ListBox of Radio buttons in combobox popup

时间秒杀一切 提交于 2020-01-23 12:55:05
问题 Ok, so my question is kind of convoluted, so I'll try to be as clear as possible. Because a collection of radio buttons does not have a 'SelectedItem/Value' property, I have collected my radioButtons into a ListBox, based on some XAML I found online. Now, in order to save space on the UI, that ListBox is taking over the content of a ComboBox popup. (So when you click the comboBox, what drops down is a list of radiobuttons in a WrapPanel.) I have been able to successfully bind the RadioButton

How to highlight entire row in WPF TreeView

三世轮回 提交于 2020-01-23 01:28:07
问题 I want to adapt the default WPF TreeView/TreeViewItem template, so that the entire row can be highlighted, as shown in the image: However, I've tried several templates from googling, but none of them can really make the effects, some wrong answers were even marked as correct... There was an answer in codeflow which seems to work, but it add extra C# code, or didn't need extra code but not working perfectly. I don't want to add extra C# code, but only change the default template. Anyone have

How apply MinWidth for ListView columns in WPF in control template?

心已入冬 提交于 2020-01-23 01:16:12
问题 Following the answer to a similar question here, I was able to set the MinWidth on the XAML page. What I would like to do is accomplish this in the control template for all GridViewColumn's in all ListView's. Is this possible? Update: I tried a simple bit of sample code below, but it does not work: <Window x:Class="WpfApplication4.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350"