controltemplate

WPF altering property on just PART_EditableTextBox of a combBox

萝らか妹 提交于 2019-12-10 16:18:33
问题 I would like to make a change to the PART_EditableTextBox of the default wpf combobox (change the background for example). I tried adding a style like this: <Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource {x:Type ComboBox}}"> <Setter Property="Control.Template"> <Setter.Value> <ControlTemplate TargetType="ComboBox"> <TextBox x:Name="PART_EditableTextBox" Background="AntiqueWhite"/> </ControlTemplate> </Setter.Value> </Setter> </Style> But that causes the rest of the default

RowStyleSelector Not Called

前提是你 提交于 2019-12-10 15:30:06
问题 I'm having difficulty getting a RowStyleSelector to work with a WPF DataGrid. In my resources, I have <loc:DetailsRowStyleSelector x:Key="detailsRowStyleSelector" AddRowStyle="{StaticResource newItemRowStyle}" StandardRowStyle="{StaticResource RowStyle}"/> Then my datagrid uses this like so: <DataGrid ... EnableRowVirtualization="false" VirtualizingStackPanel.VirtualizationMode="Standard" RowStyleSelector="{StaticResource detailsRowStyleSelector}" The constructor for the selector is called,

Foreground Color of Custom Button (ControlPresenter)

…衆ロ難τιáo~ 提交于 2019-12-10 14:31:42
问题 I am attempting to define a global button style in App.xaml, and it's mostly working as I expect. However, I just cannot figure out how to get the Foreground to work correctly. No matter what I do, I am getting the style of the default TextBlock (which sets the color to White). <Style TargetType="{x:Type Button}"> <Setter Property="Margin" Value="3, 5" /> <Setter Property="OverridesDefaultStyle" Value="True" /> <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}" />

Custom resource dictionary inside ControlTemplate or DataTemplate

强颜欢笑 提交于 2019-12-10 13:31:20
问题 EDIT: This problem occurs when using the standard .NET ResourceDictionary as well and appears to be an issue with using resource dictionaries inside control or data templates. I have a custom resource dictionary that follows a common approach to sharing resource instances. http://softnotes.wordpress.com/2011/04/05/shared-resourcedictionary-for-silverlight/ http://www.wpftutorial.net/MergedDictionaryPerformance.html public class SharedResourceDictionary : ResourceDictionary { static readonly

Passing parameters to a template

只谈情不闲聊 提交于 2019-12-10 10:26:14
问题 Say I have defined a button with rounded corners. <Style x:Key="RoundButton" TargetType="Button"> <!-- bla bla --> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <Border CornerRadius="0,5,5,0" /> <!-- bla bla --> </ControlTemplate> </Setter.Value> </Setter> </Style> I it possible that the user of this button can specify the CornerRadius? Can I use a TemplateBinding? But where should I bind to? (to Tag?) 回答1: In order to use a TemplateBinding , there must be

WPF: Bind to command from ControlTemplate

无人久伴 提交于 2019-12-09 17:18:07
问题 I am trying to add a button to a custom ListView (MyListView) which triggers a command (MyCustomCommand) defined in MyListView. I have added the button (and a title text) by applying a ControlTemplate. The problem is that I have not found a way to trigger MyCustomCommand when clicking the button. What I eventually want to achieve is to open a Popup or ContextMenu where I can select which columns should be visible in the ListView. Here's my template source: <Style TargetType="local:MyListView"

Accessing a control inside a ControlTemplate

北城余情 提交于 2019-12-09 14:27:19
问题 This is the xaml: <Page.Resources> <ControlTemplate x:Key="WeddingButtonBigTemplate" TargetType="Button"> <Grid> <Image x:Name="imgNormal" Source="../Images/Married_button2.png"/> <TextBlock x:Name="textBlock2" Style="{StaticResource RegularBlueSpecialBoldText}" LineHeight="28" LineStackingStrategy="BlockLineHeight" HorizontalAlignment="Center" Margin="10,30,10,70" TextWrapping="Wrap" TextAlignment="Center" VerticalAlignment="Stretch" > <Run FontSize="20" Text="The event of"></Run> <Run

Elegantly override style of ComboBox's ToggleButton in WPF

巧了我就是萌 提交于 2019-12-09 14:20:29
问题 I have a question regarding how to elegantly override an arbitrary element deep inside a control's visual tree. I also have attempted to resolve it in a few different ways, but I've run into several problems with each. Usually when I try three different paths and fail at each one I go downstairs, have a coffee, and ask someone smarter than myself. So here I am. Specifics: I want to flatten the style of a combo box so that it will not draw attention to itself. I want it to be similar to

Setting Validation error template from code in WPF

落花浮王杯 提交于 2019-12-09 09:23:38
问题 I have a TextBox in my WPF app. I have defined a ControlTemplate for validation error as follows: <ControlTemplate x:Key="validationTemplate"> <DockPanel LastChildFill="True"> <TextBlock DockPanel.Dock="Bottom" Text="Invalid Input: "></TextBlock> <AdornedElementPlaceholder /> </DockPanel> </ControlTemplate> My TextBox is as follows : <TextBox Validation.ErrorTemplate="{StaticResource validationTemplate}"> <TextBox.Text> <Binding Path="TEXT1" ValidatesOnDataErrors="True" validatesOnExceptions=

Change disabled listbox background to gray

匆匆过客 提交于 2019-12-09 03:38:34
问题 I have a ListBox which I need to gray out when it's disabled. Per user request it's not enough to disable it, but it also has to appear differently. shrugs I've looked in several other places and followed the examples, and it seems as if it should work, but it does not. Here are some examples I looked at: Example1, Example2. Here is my code: <Style x:Key="ListBoxStyle" TargetType="ListBox"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ListBox}">