Well u could change the size of he font and then invalidate the textblock which 
should trigger sizechanged event but it's a lil ghetto ;)

--
Sent from my mini iPad nano
(excuse my spilling and grammar as I have giant man like fingers and this 
device as small keys)

On 15/09/2010, at 5:08 PM, Colin Savage <[email protected]> wrote:

> The app is a WYSIWYG layout for arranging textblocks and barcodes and things 
> to print on a label, so I want to avoid adding content that is not going to 
> be printed to the xaml. Since the changing of the font size is initiated by 
> the user, I can access the ActualHeight after that and update the rest of the 
> UI manually.
> 
> It seems that the event only fires if it has in some way changed the layout 
> of the container, but that is contrary to what the doco says.
> 
> http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.sizechanged(VS.95).aspx
> "SizeChanged is raised whenever the size (either ActualHeight or ActualWidth) 
> has changed on the object, and is raised after the Measure and Arrange passes 
> are complete (for more information about these concepts, see Silverlight 
> Layout System). If the position of the object within a parent container 
> changes, but not the size, SizeChanged is not raised. "
> 
> In this case the ActualHeight has changed, but it doesn't fire. I'll find a 
> workaround for it, I was just wondering if anyone knew the reason.
> 
> Regards,
> Colin Savage
> 
> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of Scott Barnes
> Sent: Wednesday, 15 September 2010 4:10 PM
> To: ozSilverlight
> Subject: Re: Textblock SizeChanged
> 
> Steve's correct, Canvas doesn't really care how wide/high its children
> are in regards to itself. Encapsulating the TextBlock inside a border
> and using that as your Source of Truth should get you the results you
> desire, but yeah you have a ghetto border now :)
> 
> Not sure why FontSize doesn't trigger SizeChanged though? in theory
> the ActualWidth/ActualHeight should still trigger this event but given
> FontSize may act differently to other FrameworkElements given it uses
> glyphs etc.
> 
> 
> 
> Regards,
> 
> Scott Barnes
> 
> http://www.riagenic.com
> 
> 
> 
> On Wed, Sep 15, 2010 at 3:46 PM, Stephen Price <[email protected]> 
> wrote:
>> Without trying anything in code, I'd be guessing that putting the
>> textblock onto/into the canvas makes it behave differently than when
>> its in the border. I've seen quite a lot of sizing things behave
>> differently depending upon the parent container.
>> 
>> Have you tried it in a grid instead of a canvas? It might work
>> (guessing, have not tried it out)
>> 
>> On Wed, Sep 15, 2010 at 11:23 AM, Colin Savage <[email protected]> 
>> wrote:
>>> Before this list turns entirely into an ausdotnet trollfest, how about a
>>> Silverlight question?
>>> 
>>> 
>>> 
>>> Does anyone know why a textblock is not firing SizeChanged event when the
>>> fontsize changes?
>>> 
>>> 
>>> 
>>> Example:
>>> 
>>> <Grid x:Name="LayoutRoot" Background="White">
>>> 
>>>         <StackPanel>
>>> 
>>>         <Button Content="Resize"
>>> 
>>>                 Name="button1"
>>> 
>>>                 Click="button1_Click" />
>>> 
>>>         <TextBlock Name="result"
>>> 
>>>                    Text="Size goes here"/>
>>> 
>>>         <TextBlock Name="actual"
>>> 
>>>                    Text="Actual goes here" />
>>> 
>>>         </StackPanel>
>>> 
>>>         <Canvas Height="200"
>>> 
>>>                 HorizontalAlignment="Left"
>>> 
>>>                 Margin="57,92,0,0"
>>> 
>>>                 Name="canvas1"
>>> 
>>>                 VerticalAlignment="Top"
>>> 
>>>                 Width="311">
>>> 
>>>             <!--<Border  Canvas.Top="10"
>>> 
>>>                      Canvas.Left="10"
>>> 
>>>                      BorderBrush="Green" BorderThickness="1">-->
>>> 
>>>             <TextBlock Canvas.Top="10"
>>> 
>>>                 Canvas.Left="10"
>>> 
>>>                 Name="textblock1"
>>> 
>>>                        Width="180"
>>> 
>>>                         Text="Some Text" />
>>> 
>>>             <!--</Border>-->
>>> 
>>>         </Canvas>
>>> 
>>>     </Grid>
>>> 
>>> 
>>> 
>>>     public partial class MainPage : UserControl
>>> 
>>>     {
>>> 
>>>         public MainPage()
>>> 
>>>         {
>>> 
>>>             InitializeComponent();
>>> 
>>> 
>>> 
>>>             textblock1.SizeChanged += textblock1_SizeChanged;
>>> 
>>>         }
>>> 
>>> 
>>> 
>>>         void textblock1_SizeChanged(object sender, SizeChangedEventArgs e)
>>> 
>>>         {
>>> 
>>>             result.Text = e.NewSize.ToString();
>>> 
>>>         }
>>> 
>>> 
>>> 
>>>         private void button1_Click(object sender, RoutedEventArgs e)
>>> 
>>>         {
>>> 
>>>             textblock1.FontSize += 1;
>>> 
>>> 
>>> 
>>>             actual.Text = textblock1.ActualHeight.ToString();
>>> 
>>>         }
>>> 
>>>     }
>>> 
>>> 
>>> 
>>> 
>>> 
>>> Note that if I increase the fontsize, the ActualHeight changes,  but the
>>> SizeChanged event doesn't. Uncomment the border around the textblock and it
>>> does start firing.
>>> 
>>> 
>>> 
>>> Regards,
>>> 
>>> Colin Savage
>>> 
>>> _______________________________________________
>>> ozsilverlight mailing list
>>> [email protected]
>>> http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight
>>> 
>>> 
>> _______________________________________________
>> ozsilverlight mailing list
>> [email protected]
>> http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight
>> 
> _______________________________________________
> ozsilverlight mailing list
> [email protected]
> http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight
> 
> 
> _______________________________________________
> ozsilverlight mailing list
> [email protected]
> http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight
_______________________________________________
ozsilverlight mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight

Reply via email to