protected override void OnApplyTemplate() { base.OnApplyTemplate(); bodyTextBlock = GetTemplateChild("Body") as TextBlock; extendButton = GetTemplateChild("Button") as Button; if (bodyTextBlock != null) { if (Inlines != null) { foreach (var inline in Inlines) { bodyTextBlock.Inlines.Add(inline); } } } // InlineCollection //extendButton if (extendButton != null) { extendButton.Visibility = Visibility.Collapsed; extendButton.Click += (sender, args) => { Status = Status == TextBlockStatus.Collapsed ? TextBlockStatus.Expanded : TextBlockStatus.Collapsed; SetStatus(); }; } RefreshBodyTextBlock(); //this. }
public void RefreshBodyTextBlock() { if (bodyTextBlock != null) { bodyTextBlock.MaxLines = 0; bodyTextBlock.SizeChanged += OnTextSizeChanged; } Status = TextBlockStatus.Collapsed; if (extendButton != null) { extendButton.Visibility = Visibility.Collapsed; } }