Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Custom Control Style Question Revisited

Custom Control Style Question Revisited

Scheduled Pinned Locked Moved WPF
wpfquestiondatabasewcf
3 Posts 2 Posters 6 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kevin Marois
    wrote on last edited by
    #1

    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>
    
    L 1 Reply Last reply
    0
    • K Kevin Marois

      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>
      
      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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

      K 1 Reply Last reply
      0
      • L Lost User

        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

        K Offline
        K Offline
        Kevin Marois
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups