Print Page | Close Window

Stretch a TextBlock

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: MarkupLabel Control
Forum Description: Topics Related to Codejock MarkupLabel Control
URL: http://forum.codejock.com/forum_posts.asp?TID=22572
Printed Date: 19 April 2024 at 5:11am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Stretch a TextBlock
Posted By: Albert1
Subject: Stretch a TextBlock
Date Posted: 13 April 2015 at 6:45am
Any idea on how to render a TextBlock to fill available space.
 
Viewbox doesnt work:
 
  <Grid Width="400" Height="300">
    <Viewbox>
        <TextBlock TextWrapping="Wrap" Text="Some Text" />
    </Viewbox>
   </Grid>
 
neither ScaleTransform:
 
<TextBlock FontSize="20" Text="Some Text">
  <TextBlock.RenderTransform>
    <ScaleTransform ScaleX="2.5" ScaleY="1.0" />
  </TextBlock.RenderTransform>
</TextBlock>
 
Thank you
 


-------------
Product: Xtreme SuitePro (ActiveX) version 13.4.1 / 16.3.0

Platform: Windows Vista (32bit) - SP 2

Language: Visual Basic 6.0 (SP6)




Replies:
Posted By: jpbro
Date Posted: 13 April 2015 at 11:17pm
Try HorizontalAlignment='Stretch' - it worked for me.


-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6



Posted By: Albert1
Date Posted: 14 April 2015 at 2:40am
I guess you mean to extend a Shape or a LayoutContainer. I need to auto size a TextBlock to fill the container.
 
Try to create a file .xaml with these lines:
<Page xmlns=" http://schemas.microsoft.com/winfx/2006/xaml/presentation" rel="nofollow - http://schemas.microsoft.com/winfx/2006/xaml/presentation " xmlns:x=" http://schemas.microsoft.com/winfx/2006/xaml" rel="nofollow - http://schemas.microsoft.com/winfx/2006/xaml ">
 <Grid Width="400" Height="300" Background="#FFFFFF80">
  <Viewbox>
   <TextBlock Text="Some Text" />
  </Viewbox>
 </Grid>
</Page>
 
and execute with Internet Explorer. That's what I need.
 
 


-------------
Product: Xtreme SuitePro (ActiveX) version 13.4.1 / 16.3.0

Platform: Windows Vista (32bit) - SP 2

Language: Visual Basic 6.0 (SP6)



Posted By: jpbro
Date Posted: 14 April 2015 at 3:47pm
Not sure what you mean by execute with Internet Explorer - are you not using Codejock's MarkupLabel or other Codejock markup enabled control?

In Codejock's XAML implementation, if I drop the unsupported "ViewBox" tag, then the TextBlock fills the width and height of the Grid.


<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
 <Grid Width="400" Height="300" Background="#FFFFFF80">
   <TextBlock Background='Red' Text="Some Text" />
 </Grid>
</Page>



-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6



Posted By: jpbro
Date Posted: 16 April 2015 at 8:34pm
Any Luck?


-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6



Posted By: Albert1
Date Posted: 17 April 2015 at 2:45am
I'm giving up.
 
btw: I am using CJ MarkupControl. To write the XAML code, instead of use MarkupPad (no offence for CJ) I prefere to create a file .xaml, write the code with Notepad++ and render the .xaml code in Internet Explorer.
 
I dont want to stretch the container. I need to stretch the Fontsize to adapt to the container.
 
Without Viewbox:
<Page xmlns=" http://schemas.microsoft.com/winfx/2006/xaml/presentation" rel="nofollow - http://schemas.microsoft.com/winfx/2006/xaml/presentation " xmlns:x=" http://schemas.microsoft.com/winfx/2006/xaml" rel="nofollow - http://schemas.microsoft.com/winfx/2006/xaml ">
 <Grid Width="200" Height="100" Background="#FFFFFF80">
  <TextBlock Background='Red' Text="Some Text" />
 </Grid>
</Page>
 
 
and what I need (using Viewbox or something else ...):
 
<Page xmlns=" http://schemas.microsoft.com/winfx/2006/xaml/presentation" rel="nofollow - http://schemas.microsoft.com/winfx/2006/xaml/presentation " xmlns:x=" http://schemas.microsoft.com/winfx/2006/xaml" rel="nofollow - http://schemas.microsoft.com/winfx/2006/xaml ">
 <Grid Width="200" Height="100" Background="#FFFFFF80">
  <Viewbox>
   <TextBlock Background='Red' Text="Some Text" />
  </Viewbox>
 </Grid>
</Page>
 
 
The scope was to automatically resize the content. With MarkupLabel you can autoresize all objects excluding the text (or I am not able to so I asked here).
 
 


-------------
Product: Xtreme SuitePro (ActiveX) version 13.4.1 / 16.3.0

Platform: Windows Vista (32bit) - SP 2

Language: Visual Basic 6.0 (SP6)




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net