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. add controls dyanmically in Control Template

add controls dyanmically in Control Template

Scheduled Pinned Locked Moved WPF
wpfhelpquestion
1 Posts 1 Posters 0 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.
  • S Offline
    S Offline
    salon
    wrote on last edited by
    #1

    I need to add styles for the controls in a panel dynamically, I have created object of the control classes and setted the properties like this

    properties.Add(TextBox.FontFamilyProperty, "Arial");

    Now I want to add a ControlTemplate similarly, I have created object of ControlTemplate like this

           ControlTemplate ctrl = new ControlTemplate();
            ctrl.TargetType = typeof(edtPanel);
    
            TextBlock txtbl = new TextBlock();
            txtbl.Text = "Test Cotnrol Tempalte";
    
            properties.Add(TextBox.TemplateProperty, ctrl);
    

    edtPanel is the panel name where i need to add all the controls Now i want to add the txtbl inside the ControlTemplate ctrl, but I don't have any idea how??? Does anybody help me? Thanks in advance,

    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