Get Font Size value

2 posts, 0 answers
  1. Peter
    Peter avatar
    17 posts
    Member since:
    Mar 2017

    Posted 11 May 2017 Link to this post

    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

  2. Nikolay Petrov
    Admin
    Nikolay Petrov avatar
    308 posts

    Posted 15 May 2017 Link to this post

    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
     
Back to Top