controltemplate

Replace part of default template in WPF

大憨熊 提交于 2019-11-26 19:35:51
问题 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.

Access ResourceDictionary items programmatically

。_饼干妹妹 提交于 2019-11-26 14:07:58
问题 I have a Silverlight controls assembly, called "MySilverlightControls". Several folders down into that assembly I have a class which extends a grid column from a third party vendor, let's call it "MyImageColumn.cs". I have also created a resource dictionary called Generic.xaml , this is situated in the Themes folder of the assembly. In that resource dictionary i have defined a ControlTemplate called MyImageColumnTemplate : <ControlTemplate x:Name="MyImageColumnTemplate" > <Grid Margin="8,8,4

How to change MahApps.Metro dialog content template width?

為{幸葍}努か 提交于 2019-11-26 11:18:18
问题 I would like to change the base template of the MahApps.Metro dialogs (or create a new dialog type), because I would like to show them in a narrow login window. Right now almost all the second words in the message are in a new row, but there are nice big spaces on the right and the left side, which I would like to reduce. I\'ve found in BaseMetroDialog.xaml that the message dialog is divided into three parts vertically: 25% space on left side, 50% for the content and 25% space on the right

In WPF, why doesn&#39;t TemplateBinding work where Binding does?

谁说我不能喝 提交于 2019-11-26 11:11:10
问题 Ok... this is leaving me scratching my head. I have two WPF controls--one\'s a user control and the other\'s a custom control. Let\'s call them UserFoo and CustomFoo. In the control template for CustomFoo, I use an instance of UserFoo which is a named part so I can get to it after the template is applied. That works fine. Now both UserFoo and CustomFoo have a Text property defined on them (independently, i.e. not a shared DP using AddOwner. Don\'t ask...) that are both declared like this...

Creating an image+text button with a control template?

被刻印的时光 ゝ 提交于 2019-11-26 11:03:24
问题 I am tired of creating the same image+text button over and over again, and I would like to move the markup to a control template. Here is my problem: I need to provide template bindings to add the image and text to the templated button, and the Button control doesn\'t seem to have properties that I can bind to. My template looks like this so far (with \'???\' for the unknown template bindings): <ControlTemplate x:Key=\"ImageButtonTemplate\" TargetType=\"{x:Type Button}\"> <StackPanel Height=\

How to create a WPF Window without a border that can be resized via a grip only?

时光怂恿深爱的人放手 提交于 2019-11-26 08:46:24
问题 If you set ResizeMode=\"CanResizeWithGrip\" on a WPF Window then a resize grip is shown in the lower right corner, as below: If you set WindowStyle=\"None\" as well the title bar disappears but the grey bevelled edge remains until you set ResizeMode=\"NoResize\" . Unfortunately, with this combination of properties set, the resize grip also disappears. I have overridden the Window \'s ControlTemplate via a custom Style . I want to specify the border of the window myself, and I don\'t need

Template Binding in Control template

这一生的挚爱 提交于 2019-11-26 08:16:26
问题 I have the following control template. I wish to set the source property for the image control in the control template using Template Binding. But since this is a control template for button control and the button control doesn\'t have source property, i can\'t use TemplateBinding in this case. <ControlTemplate x:Key=\"BtnTemplate\" TargetType=\"Button\"> <Border CornerRadius=\"5\" Margin=\"15\" Cursor=\"Hand\"> <StackPanel> <Image Name=\"Img\" Style=\"{StaticResource ImageStyle}\" Source=\

ControlTemplate for existing controls in WPF

青春壹個敷衍的年華 提交于 2019-11-26 03:16:00
问题 How to get existing control\'s ControlTemplate in WPF in XAML format (visual tree)? This is to help to create new ControlTemplate with the help of existing template. 回答1: The styles along with template examples are up on MSDN for download, see the Default WPF Themes link. However you can also extend the existing style without redefining everything by using the BasedOn attribute. 回答2: Check out StyleSnooper: (source: intuidev.com) It will dump out the standard styles (and therefore templates

ResourceDictionary in a separate assembly

匆匆过客 提交于 2019-11-26 00:45:45
问题 I have resource dictionary files (MenuTemplate.xaml, ButtonTemplate.xaml, etc) that I want to use in multiple separate applications. I could add them to the applications\' assemblies, but it\'s better if I compile these resources in one single assembly and have my applications reference it, right? After the resource assembly is built, how can I reference it in the App.xaml of my applications? Currently I use ResourceDictionary.MergedDictionaries to merge the individual dictionary files. If I