Set minimum height on TableRow in FlowDocument (WPF)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Is it possible to set the minimum height on a TableRow or TableCell in a
FlowDocument? Within a RichTextBox I would like an existing table to have a
minimum height without having to fill it will content.

Thanks,

Anthony.
 
Hi Anthony,

Welcome to MSDN Managed Newsgroup.

This is a quick note to let you know that I am performing research on this
issue and will get back to you as soon as possible. I appreciate your
patience.



Sincerely,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
How come I never get this level of service when I post issues?

Seriously though, is there a mechanism that should be followed for
escalation of problems? I get some doozies from time to time...
 
Hi Anthony,

Unlike an UIElement, a ContentElement is usually used to display data in
flow layout and doesn't have a MinHeight (dependency) property. TableCell
is a ContentElement.

I'm not sure if following workaround will work for you:

We can set TableCell's Padding property to make some extra room before the
bottom border:

<RichTextBox >
<FlowDocument>
<Table>
<TableRowGroup>
<TableRow>
<TableCell Padding="0,0,0,20" >
<Paragraph>Paragraph 1</Paragraph>
</TableCell>
</TableRow>
</TableRowGroup>
</Table>
<Paragraph>Paragraph 2</Paragraph>
</FlowDocument>
</RichTextBox>


If you're using code, you can determine if the TableCell has content or not
to use different padding size:

Pseudo code:
If(myTableCell.Blocks.Count == 0)
{
myTableCell.Padding = someThicknessForEmptyTableCell;
}
else
{
myTableCell.Padding =
someThicknessForTableCellsWithContent;
}


Please let me know if it helps.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Chris,

Anthony is a MSDN subscriber. A MSDN subscriber can register a nospam
posting alias (http://blogs.msdn.com/msdnts/pages/postingAlias.aspx) and
post questions in MSDN Managed Newsgroups
(http://msdn.microsoft.com/subscriptions/managednewsgroups/list.aspx).
Posts of such kind are guaranteed to get an initial response within 24
business hours and further responses within 48 business hours (response
could be either from MSFT or community). My signature should contain more
information.

Thanks.


Sincerely,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Walter,

Thanks for your reply. I had considered using padding to achieve the effect,
however the someThicknessForTableCellsWithContent value in your code example
is proving difficult to calculate.

Is there a simple way to get the current hight of the content in a table
cell. I'm doing things like calculating the number of lines (using multiple
calls to GetLineStartPosition) and multiplying it by the height of the font,
but this isn't very accurate. It really needs to be pixel perfect or it looks
silly as the user adds content.

Thanks again,

Anthony.
 
Hi Walter,

I found a way to measure the size of the cell:

Rect startRect = cell.ElementStart.GetCharacterRect(LogicalDirection.Forward);
Rect endRect =
cell.ElementEnd.GetNextInsertionPosition(LogicalDirection.Backward).GetCharacterRect(LogicalDirection.Forward);
double height = (endRect.Bottom - startRect.Top);


Thanks for your suggestion. Works great now!


Anthony.



Anthony Meehan said:
Hi Walter,

Thanks for your reply. I had considered using padding to achieve the effect,
however the someThicknessForTableCellsWithContent value in your code example
is proving difficult to calculate.

Is there a simple way to get the current hight of the content in a table
cell. I'm doing things like calculating the number of lines (using multiple
calls to GetLineStartPosition) and multiplying it by the height of the font,
but this isn't very accurate. It really needs to be pixel perfect or it looks
silly as the user adds content.

Thanks again,

Anthony.

"Walter Wang [MSFT]" said:
Hi Anthony,

Unlike an UIElement, a ContentElement is usually used to display data in
flow layout and doesn't have a MinHeight (dependency) property. TableCell
is a ContentElement.

I'm not sure if following workaround will work for you:

We can set TableCell's Padding property to make some extra room before the
bottom border:

<RichTextBox >
<FlowDocument>
<Table>
<TableRowGroup>
<TableRow>
<TableCell Padding="0,0,0,20" >
<Paragraph>Paragraph 1</Paragraph>
</TableCell>
</TableRow>
</TableRowGroup>
</Table>
<Paragraph>Paragraph 2</Paragraph>
</FlowDocument>
</RichTextBox>


If you're using code, you can determine if the TableCell has content or not
to use different padding size:

Pseudo code:
If(myTableCell.Blocks.Count == 0)
{
myTableCell.Padding = someThicknessForEmptyTableCell;
}
else
{
myTableCell.Padding =
someThicknessForTableCellsWithContent;
}


Please let me know if it helps.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
I think i'm very confused.

I'm an MSDN subsciber (and have been for 10+ years now), have my address
registered via that posting alias, and post questions/problems to these
groups all the time that go completly unanswered. As far as I can tell the
Newgroup I'm replying on is the same one you're talking about.

I've seen many other people ask this question over the last few years, and
never gotten a good answer. Could you please explain to me how I could post
a question, and to where I should post it, that it's guaranteed to get a
response with 24 to 48 hours? If nothing else, it would help when I see
others ask this.

Given the volume of traffic on this (and other) groups, and the number of
MSDN subscribers, I would exect to see a far higher response rate by people
with [MSFT] in their taglines.

--
Chris Mullins

"Walter Wang [MSFT]" said:
Hi Chris,

Anthony is a MSDN subscriber. A MSDN subscriber can register a nospam
posting alias (http://blogs.msdn.com/msdnts/pages/postingAlias.aspx) and
post questions in MSDN Managed Newsgroups
(http://msdn.microsoft.com/subscriptions/managednewsgroups/list.aspx).
Posts of such kind are guaranteed to get an initial response within 24
business hours and further responses within 48 business hours (response
could be either from MSFT or community). My signature should contain more
information.

Thanks.


Sincerely,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.
 
Hi Chris,

Please use refer to following thread for more information:

#[announcement] MSDN Managed Newsgroup Posting Alias Setup Guide in
microsoft.public.msdn.general
http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?dg=m
icrosoft.public.msdn.general&tid=9f2acdde-6365-4c77-a267-8b4436d057eb&cat=en
_us_b06bd5b8-795b-41ec-8dac-d437515437cc&lang=en&cr=us&sloc=en-us&m=1&p=1


We can discuss this there if needed. Thanks.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top