controltemplate

Where can i find the default WPF Control templates?

冷暖自知 提交于 2019-11-28 20:10:01
As per this MSDN link, There is no way to replace only part of the visual tree of a control; to change the visual tree of a control you must set the Template property of the control to its new and complete ControlTemplate . I am trying to disable the click behaviour of GridViewColumnHeader ( I need to remove some triggers in the original control template), but i am not able to find the native "ColumnHeaderContainerStyle". All those i have found seem to have already done some customization and it is being difficult to get the original look and feel. Can someone please suggest me how/where can i

WPF ControlTemplate: How to provide a default value for TemplateBinding?

对着背影说爱祢 提交于 2019-11-28 07:18:29
I am writing a WPF control that subclasses a Button. I then provide a default style in Themes\generic.xaml, that looks like this (simplified): <Style TargetType="{x:Type WPFControls:MyButton}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type WPFControls:MyButton}"> <Button x:Name="PART_Button" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" /> </ControlTemplate> </Setter.Value> </Setter> </Style> I would like the user to have the opportunity to change the control's background, but if he doesn't, I'd like to provide default

ControlTemplate with DataTrigger Vs. DataTemplate with DataTemplateSelector

China☆狼群 提交于 2019-11-28 07:01:37
I have a generic control which displays an editor based on the type property inside a ViewModel. Currently it's implemented using Control , ControlTemplate and DataTrigger like this - <Control x:Name="MainControl" Grid.Column="1" TargetUpdated="OnTargetUpdated"> <Control.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding Path=EditorType}" Value="{x:Static view:EditorType.Bool}"> <Setter Property="Control.Template" Value="{StaticResource boolTemplate}" /> </DataTrigger> <DataTrigger Binding="{Binding Path=EditorType}" Value="{x:Static view:EditorType.Text}"> <Setter Property=

wpf error template - red box still visible on collapse of an expander

依然范特西╮ 提交于 2019-11-28 07:01:09
I'm doing some validation on the DataSource of TextBox that's within an Expander and have found that once a validation error has been triggered, if I collapse the Expander, the red box stays where the TextBox would have been. <Expander Header="Blah Blah Blah"> <TextBox Name="TextBox" Validation.ErrorTemplate="{DynamicResource TextBoxErrorTemplate}" Text="{Binding Path=Blah, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" /> </Expander> I've tried to get round this by binding the visibility of the Error Template to the Expander, however I think there's something wrong with the

ContentPresenter within ControlTemplate cannot change attached dependency property

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 01:13:27
Why does the following simplified code not sets the font-size of the TextBlock to 50? <Window.Resources> <ControlTemplate TargetType="ContentControl" x:Key="Test"> <ContentPresenter TextBlock.FontSize="50" /> </ControlTemplate> </Window.Resources> <Grid> <ContentControl Template="{StaticResource Test}"> <TextBlock>Test should be rendered big</TextBlock> </ContentControl> </Grid> If I change the value of the FontSize property, visual studio shows me the text in the size I want. After compiling or executing the app, the size of the textblock is always reset to its default size. I have also

Silverlight 3: ListBox DataTemplate HorizontalAlignment

做~自己de王妃 提交于 2019-11-27 20:04:23
I have a ListBox with it's ItemTemplate bound to a DataTemplate. My problem is I cannot get the elements in the template to stretch to the full width of the ListBox. <ListBox x:Name="listPeople" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0,0,0,0" Background="{x:Null}" SelectionMode="Extended" Grid.Row="1" ItemTemplate="{StaticResource PersonViewModel.BrowserDataTemplate}" ItemsSource="{Binding Mode=OneWay, Path=SearchResults}" > </ListBox> <DataTemplate x:Key="PersonViewModel.BrowserDataTemplate"> <ListBoxItem HorizontalAlignment="Stretch" VerticalAlignment="Stretch">

Replace part of default template in WPF

懵懂的女人 提交于 2019-11-27 18:45:55
is there any "best practice" way to replace a part of the default template. The current use case is a treeview. As default, the treeview has this small triangle shapes to expand and collapse. I know how to replace these if I replace the whole control template, as shown in the code below. I am not sure if there is a way to "keep all default, just change XY". Its not a style, I basically need to replace a part of an existing control template. To illustrate, take a look at the following XAML. The first smaller block is the relevant XAML I want to be able to adapt. The bigger second and third part

WPF ControlTemplate breaks style

不问归期 提交于 2019-11-27 16:19:14
问题 The stuff that does work I need to style controls of a certain type that are children of a StackPanel. I'm using: <StackPanel> <StackPanel.Resources> <Style TargetType="{x:Type TextBlock}">...</Style> </StackPanel.Resources> <TextBlock ...> ... </StackPanel> And this works fine! Each TextBlock looks to the resources of it's parent (the StackPanel) to find out how it should be styled. It doesn't matter how far down you nest the TextBlock down a StackPanel... if it doesn't find a style in its

How to access a WPF control located in a ControlTemplate?

隐身守侯 提交于 2019-11-27 13:56:45
Usually, the WPF controls are declared in the .xaml files and not in the code behind (.xaml.cs files). However, sometimes I need to use some of those controls in code behind in order to manipulate them. How can I get the handle of such a control if it "resides" in the xaml file? You can use the FindName() method of the ControlTemplate class. // Finding the grid that is generated by the ControlTemplate of the Button Grid gridInTemplate = (Grid)myButton1.Template.FindName("grid", myButton1); I'm unsure about what you're asking, so I'll try and answer both instances that I'm interpreting as your

Where can i find the default WPF Control templates?

假如想象 提交于 2019-11-27 12:43:53
问题 As per this MSDN link, There is no way to replace only part of the visual tree of a control; to change the visual tree of a control you must set the Template property of the control to its new and complete ControlTemplate . I am trying to disable the click behaviour of GridViewColumnHeader ( I need to remove some triggers in the original control template), but i am not able to find the native "ColumnHeaderContainerStyle". All those i have found seem to have already done some customization and