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. .NET (Core and Framework)
  4. Initialize Textblock after changing Inlines [modified]

Initialize Textblock after changing Inlines [modified]

Scheduled Pinned Locked Moved .NET (Core and Framework)
questionhelp
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.
  • D Offline
    D Offline
    Defender NF
    wrote on last edited by
    #1

    Hello everyone Since Inlines (CollectionInlines) arnt a dependencyproperty i made a TextBox with dependency Inlines, the Code:

    public InlineCollection InlineCollection
    {
    get
    {
    return (InlineCollection)GetValue(InlineCollectionProperty);
    }
    set
    {
    SetValue(InlineCollectionProperty, value);
    }
    }

        public static readonly DependencyProperty InlineCollectionProperty = DependencyProperty.Register(
            "InlineCollection",
            typeof(InlineCollection),
            typeof(InlineTextBlock),
                new UIPropertyMetadata((PropertyChangedCallback)((sender, args) =>
                {
                    InlineTextBlock textBlock = sender as InlineTextBlock;
    
                    if (textBlock != null)
                    {
    
    
                        textBlock.Inlines.Clear();
    
                        InlineCollection inlines = args.NewValue as InlineCollection;
                        InlineCollection oldinlines = args.OldValue as InlineCollection;
    
                        if (inlines != null)
                        {
                            textBlock.Inlines.AddRange(inlines.ToList());
                        }
    
                        else
    
                            textBlock.Inlines.AddRange(oldinlines.ToList());
                            
                            
                        
                    }
                })));
    

    The TextBlock has normally some text after that it gets new inlines, if the Inlines it gets are empty it should get its first(default) text again. Now the Problem: if it had a the first a text via Inlines then everything is ok coz i can get them again with the oldvalue, if it has a the first normal text with no inlines then the textblock doesnt show nothing because of: textBlock.Inlines.AddRange(oldinlines.ToList()); (no oldvalue of the Inlines) how can i set the first text at the ende if in this case? any ideas? Thanks in Advance. Cheers Def.

    modified on Tuesday, April 12, 2011 9:02 AM

    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