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. Replace Expander's Content at Runtime

Replace Expander's Content at Runtime

Scheduled Pinned Locked Moved WPF
1 Posts 1 Posters 13 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'm trying to create a specialized expander that has some pre-defined controls in place of the ContentPresenter. I created a class called CustomExpander. The content I want to place can be layed out differently depending on a DP called ContentAlignment. When set to Left, the content is arranged one way, and when set to right, the content is arranged another way. I'm trying to do this with different ContentControl.

    public class CustomExpander : Expander
    {
    #region DP's
    #region DP ContentAlignment
    public static readonly DependencyProperty ContentAlignmentProperty =
    DependencyProperty.Register("ContentAlignment",
    typeof(ContentAlignment),
    typeof(CustomExpander),
    new PropertyMetadata(ContentAlignment.Left, new PropertyChangedCallback(OnContentAlignmentChanged)));

    public ContentAlignment ContentAlignment
    {
        get { return (ContentAlignment)GetValue(ContentAlignmentProperty); }
        set { SetValue(ContentAlignmentProperty, value); }
    }
    
    
    private static void OnContentAlignmentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        var control = (CustomExpander)d;
    }
    #endregion
    #endregion
    
    #region CTOR
    static CustomExpander()
    {
        DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomExpander),
            new FrameworkPropertyMetadata(typeof(CustomExpander)));
    }
    #endregion
    

    }

    public enum ContentAlignment
    {
    Left,
    Right
    }

    Here's my style so far:

    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