locked
Textblocks that aren't showing RRS feed

  • Question

  •  Hi,

    For a project we are currently building, we have build a waterfall chart. Each of the bars contains a textblock representing the value of the bar.

    We created it using several (10+) levels of nested grids, to profit from the automatic resizing. The problem we are now experiencing is that randomly, some textblocks aren't showing. Note that it is completely random: we run the same code several times and sometimes all textblocks are showing, sometimes a few are hidden and so forth.

    My question is the following: can this be caused by Silverlight's rendering engine that doesn't like so many levels of nested grids? Is there some limitation on that? Or do you have any other idea on what might cause textblocks sometimes not to show (I know it's a shot in the wild, but...)

    Thanks!

     

    Thursday, December 4, 2008 10:14 AM

Answers

  • Ok, if i am to take wild shot,

    1. i would first make sure that there are no emty textblock by initializing it first with some intial value say eg. text ="I exist", and give fixed width and height change back color, and see if the scenario repeats itself.

    2. If it repeats than i would try to check if the textblock exist?? in the page when it is not showing by looping all the UIElement or using findname or visual web tree.

    3. It should exist [as you said it randomly showing and not showing] and still not showing then maybe due to resizing of the grid, the textblock maynot be resizing itself. And that should take the width of text value. In this case eg "i exist".[that i have initialized]

    Try this test cases and see if your problem gets solved or not.

    and if this post was helpful then please 'Mark as Answer' - many thanks

    Sharker Khaleed Mahmud (MCPD)
    Software Developer

    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.

     

    Thursday, December 4, 2008 10:27 AM
  • Without seeing your code, it's hard to say, but it may be dynamic sizing and TextBlocks when you have TextWrap turned on.  I have seen cases where when I have a Textblock with wrap inside a dynamically sized container (where width and height are not defined explicitly) that parts of the words get cut off and sometimes not seen altogether.  The only way I was able to fix it was to define the width of the TextBlock, but leave the height alone so the text would wrap correctly.

    Another, although probably less likely issue, could be an issue of timing vs. render order.  It could be related to how you are adding your TextBlocks into the grids (programmatically?) and if there are any other element overlapping.  The overlap may change depending on the timing of how the elements are added to the Children collection of the grid.  If you suspect this is the case, you could override the z-index of the TextBlocks to insure they are always on top.

    Thursday, December 4, 2008 10:36 AM

All replies

  • Ok, if i am to take wild shot,

    1. i would first make sure that there are no emty textblock by initializing it first with some intial value say eg. text ="I exist", and give fixed width and height change back color, and see if the scenario repeats itself.

    2. If it repeats than i would try to check if the textblock exist?? in the page when it is not showing by looping all the UIElement or using findname or visual web tree.

    3. It should exist [as you said it randomly showing and not showing] and still not showing then maybe due to resizing of the grid, the textblock maynot be resizing itself. And that should take the width of text value. In this case eg "i exist".[that i have initialized]

    Try this test cases and see if your problem gets solved or not.

    and if this post was helpful then please 'Mark as Answer' - many thanks

    Sharker Khaleed Mahmud (MCPD)
    Software Developer

    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.

     

    Thursday, December 4, 2008 10:27 AM
  • Without seeing your code, it's hard to say, but it may be dynamic sizing and TextBlocks when you have TextWrap turned on.  I have seen cases where when I have a Textblock with wrap inside a dynamically sized container (where width and height are not defined explicitly) that parts of the words get cut off and sometimes not seen altogether.  The only way I was able to fix it was to define the width of the TextBlock, but leave the height alone so the text would wrap correctly.

    Another, although probably less likely issue, could be an issue of timing vs. render order.  It could be related to how you are adding your TextBlocks into the grids (programmatically?) and if there are any other element overlapping.  The overlap may change depending on the timing of how the elements are added to the Children collection of the grid.  If you suspect this is the case, you could override the z-index of the TextBlocks to insure they are always on top.

    Thursday, December 4, 2008 10:36 AM