This is a migrated thread and some comments may be shown as answers.

Get Font Size value

1 Answer 66 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 11 May 2017, 10:40 AM

How to get a vaule form TextBlock for FontSize.

I need to get number 14 !

 

<TextBlock Grid.Row="1"
                                   TextWrapping="Wrap"
                                   Margin="5"
                                   Name="TextBlockAbout"
                                   FontSize="14">
 </TextBlock>

 

var fSize = TextBlockAbout.GetProperty<TextBlock>("FontSize");

 

Regards,

Peter

1 Answer, 1 is accepted

Sort by
0
Nikolay Petrov
Telerik team
answered on 15 May 2017, 09:38 AM
Hello Peter,

There is a simple sequence about getting a WPF element property. In this case the following lines have to do the job:

// finding and casting the element to TextBlock
var myBox = ActiveApplication.MainWindow.Find.ByName("TextBlockAbout").CastAs<ArtOfTest.WebAii.Controls.Xaml.Wpf.TextBlock>();
 
// printing its font size property
Console.WriteLine(myBox.FontSize.ToString());

Best Regards,
Nikolay Petrov
Telerik by Progress
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
Peter
Top achievements
Rank 1
Answers by
Nikolay Petrov
Telerik team
Share this question
or