Custom Control Style Question Revisited
-
I've asked about this already, but I'm not really getting it. I'm asking this again with more detail in the hopes that it'll make more sense. Lets say I develop a custom control that have a TextBlock over a TextBox[^]. I have defind colors for Normal and Mouse Over Here's the XAML for my control. It's pretty simple:
<Setter Property="Padding" Value="1"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type local:TextBoxEx}"> <StackPanel Orientation="Vertical"> <Border Padding="{Binding Padding, RelativeSource={RelativeSource TemplatedParent}}" Margin="{Binding Margin, RelativeSource={RelativeSource TemplatedParent}}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> <StackPanel Orientation="Vertical"> <TextBlock x:Name="caption" Foreground="{StaticResource CaptionNormalColor}" Text="{TemplateBinding Caption}"/> <TextBox x:Name="text" Foreground="{StaticResource TextNormalColor}" Text="{TemplateBinding Text}"/> </StackPanel> </Border> </StackPanel> <ControlTemplate.Triggers> <Trigger P</x-turndown>
-
I've asked about this already, but I'm not really getting it. I'm asking this again with more detail in the hopes that it'll make more sense. Lets say I develop a custom control that have a TextBlock over a TextBox[^]. I have defind colors for Normal and Mouse Over Here's the XAML for my control. It's pretty simple:
<Setter Property="Padding" Value="1"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type local:TextBoxEx}"> <StackPanel Orientation="Vertical"> <Border Padding="{Binding Padding, RelativeSource={RelativeSource TemplatedParent}}" Margin="{Binding Margin, RelativeSource={RelativeSource TemplatedParent}}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> <StackPanel Orientation="Vertical"> <TextBlock x:Name="caption" Foreground="{StaticResource CaptionNormalColor}" Text="{TemplateBinding Caption}"/> <TextBox x:Name="text" Foreground="{StaticResource TextNormalColor}" Text="{TemplateBinding Text}"/> </StackPanel> </Border> </StackPanel> <ControlTemplate.Triggers> <Trigger P</x-turndown>
Making color changes to parts of controls that already have "part resources" defined in generic.xaml is not customizing; it is annoying.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
-
Making color changes to parts of controls that already have "part resources" defined in generic.xaml is not customizing; it is annoying.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
You're missing the point. When you buy a third party control, like say from Infragistics, and you use it in your app, when you write your own theme the third party control respects it. I'm trying to understand how to make my control work the same way
In theory, theory and practice are the same. But in practice, they never are.” If it's not broken, fix it until it is. Everything makes sense in someone's mind.