Reputation: 29
Is it possible to give width for a textblock inline element in WPF? I am using Run to add inline elements to text block. I want each run to be of same fixed size.But I couldn't find width property for Run.
For example
TextBlock txtblck = new TextBlock();
txtblck.Inlines.Add(new Run() { Text = "abc" });
txtblck.Inlines.Add(new Run() { Text = "def" });
I want both the Runs to be of same width. Is it possible? Please help me.
Thanks in advance.
Upvotes: 0
Views: 1050
Reputation: 2128
You can use InlineUIContainer:
TextBlock txtblck = new TextBlock();
txtblck.Inlines.Add(new InlineUIContainer
{
Child = new TextBlock
{
Text = "abc",
Width = 100
}
});
txtblck.Inlines.Add(new InlineUIContainer
{
Child = new TextBlock
{
Text = "def",
Width = 100
}
});
Upvotes: 4