TextBlock textBlock = new TextBlock(); Button button = new Button() { Content = "Click me!" }; textBlock.Inlines.Add(button);
TextBlock textBlock = new TextBlock(); Hyperlink hyperlink = new Hyperlink(); hyperlink.Inlines.Add("Click me!"); hyperlink.NavigateUri = new Uri("https://www.example.com"); textBlock.Inlines.Add(hyperlink);This example demonstrates how to add a hyperlink element as a child of a TextBlock using the Inlines property. It also sets the NavigateUri property to a URL to allow the user to navigate to a website when clicking the hyperlink. Package library: System.Windows.Controls.