controltemplate

Access ResourceDictionary items programmatically

泪湿孤枕 提交于 2019-11-27 08:22:21
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,4" MaxHeight="32" MaxWidth="32"> <Grid.Resources> <localGrid:StatusColumnImageConverter x:Key=

In WPF, why doesn't TemplateBinding work where Binding does?

孤人 提交于 2019-11-27 04:44:21
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... public static readonly DependencyProperty TextProperty = DependencyProperty.Register( "Text", typeof(string)

How to change MahApps.Metro dialog content template width?

别等时光非礼了梦想. 提交于 2019-11-27 04:40:22
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 side. I would like to change these numbers. But how could I change the control template of BaseMetroWindow

Creating an image+text button with a control template?

对着背影说爱祢 提交于 2019-11-27 04:06:35
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="Auto" Orientation="Horizontal"> <Image Source="{TemplateBinding ???}" Width="24" Height="24" Stretch="Fill"/>

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

∥☆過路亽.° 提交于 2019-11-27 01:51:16
问题 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

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

走远了吗. 提交于 2019-11-27 01:40:34
问题 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

ControlTemplate with DataTrigger Vs. DataTemplate with DataTemplateSelector

我的未来我决定 提交于 2019-11-27 01:40:19
问题 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>

ContentPresenter within ControlTemplate cannot change attached dependency property

爷,独闯天下 提交于 2019-11-26 23:29:41
问题 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

Template Binding in Control template

最后都变了- 提交于 2019-11-26 22:14:52
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="temp.jpg" Height="100" Width="100" Margin="5"></Image> <Label Content="{TemplateBinding Content}" Background="Transparent

Binding SolidColorBrush to ControlTemplate Background

可紊 提交于 2019-11-26 22:08:15
问题 Hi i tried to bind SolidColorBrush to the Background property of border in Control Template For TabItem. But When im changing the value of SolidColorBrush Resource it Says "Cannot set a property on object '#FF808080' because it is in a read-only state." Where as with stock button without ControlTemplate it works perfectly. Here's my code. (XAML) <Window.Resources> <SolidColorBrush x:Key="SolidColorBrush2" Color="Gray"/> <SolidColorBrush x:Key="SolidColorBrush3" Color="Black"/> <Style x:Key=