Click here to Skip to main content
15,884,007 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Adding hyperlink button column in silverlight grid from codebehind? Pin
#realJSOP13-May-10 8:52
mve#realJSOP13-May-10 8:52 
QuestionSilverlight 4 Grid in Code. Access Row Background Pin
Paul Shearing13-May-10 6:45
Paul Shearing13-May-10 6:45 
AnswerRe: Silverlight 4 Grid in Code. Access Row Background Pin
Abhinav S13-May-10 18:51
Abhinav S13-May-10 18:51 
QuestionWPF Rotate transform issue Pin
Shane555513-May-10 5:20
Shane555513-May-10 5:20 
AnswerRe: WPF Rotate transform issue Pin
Insincere Dave13-May-10 6:07
Insincere Dave13-May-10 6:07 
GeneralRe: WPF Rotate transform issue Pin
Shane555513-May-10 6:15
Shane555513-May-10 6:15 
QuestionWPF for Pipe networks Pin
Dimitris Nemtsov13-May-10 3:21
Dimitris Nemtsov13-May-10 3:21 
QuestionTexBlock Size [SOLVED!] Pin
#realJSOP13-May-10 2:51
mve#realJSOP13-May-10 2:51 
I have a ListBox with a custom item template, as follows:

<ListBox x:Name="AheadListBox" 
         FontSize="20" 
         BorderBrush="Transparent" BorderThickness="0,0,0,0" 
         Background="Transparent" 
         ScrollViewer.VerticalScrollBarVisibility="Auto" 
         ScrollViewer.HorizontalScrollBarVisibility="Hidden">
    <ListBox.ItemTemplate>
	<DataTemplate>
 	    <Grid >
		<Grid.ColumnDefinitions>
		    <ColumnDefinition Width="Auto" />
		    <ColumnDefinition Width="*" />
		</Grid.ColumnDefinitions>
	        <Ellipse Grid.Column="0" Width="20" Height="20" 
                         VerticalAlignment="Top" 
                         HorizontalAlignment="Left" 
                         Margin="5,0,0,0">
		    <Ellipse.Fill>
			<RadialGradientBrush GradientOrigin=".5,.3">
			    <GradientStop Color="LightSteelBlue" Offset="0.05"/>
			    <GradientStop Color="DarkBlue" Offset="0.9"/>
			    <GradientStop Color="DarkBlue" Offset="1"/>
			</RadialGradientBrush>
		    </Ellipse.Fill>
		</Ellipse>

		<TextBlock Grid.Column="1" 
                           Text="Some really long text string to test the veracity of my XAML Layout. Of course, nothing works the first time where Silverlight is concerned" 
                           Margin="10,0,10,0" 
                           TextWrapping="Wrap" />

	    </Grid>
	</DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>


I want the TextBlock to automatically grow vertically to accomodate all of the text it contains. Things I've tried:

0) At first, I had a StackPanel for a container, but I changed to a Grid to see if that would fix it (no fix was forthcoming).

1) I tried using a Label control instead of a TextBlock.

2) If I manually insert a "\r\n" somewhere in the string, it will grow as expected, but that's not the way the text will be fed to the control.

3) Setting Height="Auto" doesn't appear to have any effect.

4) I also tried calling ListBox.InvalidateMeasure() and ListBox.InvalidateArrange() after the listbox was populated.

5) If I set a hard-coded width for the TextBlock in the XAML, the TextBlock grows vertically as expected.

One other aspect of control (just in case you missed it) - the ListBox is set to expand/contract with its parent container, so the amount of space available to the listbox item will change accordingly.

It's starting to look like I have to do this manually. So much for separating the layout from the business logic...


SOLUTION ===============================


I had to set the horizontal scrollbar to disabled. Once I did that, it bahaved the way I thought it was supposed to.
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
modified on Thursday, May 13, 2010 1:17 PM

QuestionWPF cascaded combo Pin
bindum3112-May-10 20:22
bindum3112-May-10 20:22 
AnswerRe: WPF cascaded combo Pin
Venkatesh Mookkan12-May-10 22:41
Venkatesh Mookkan12-May-10 22:41 
GeneralRe: WPF cascaded combo Pin
bindum3112-May-10 23:30
bindum3112-May-10 23:30 
GeneralRe: WPF cascaded combo Pin
Venkatesh Mookkan13-May-10 0:19
Venkatesh Mookkan13-May-10 0:19 
GeneralRe: WPF cascaded combo Pin
bindum3113-May-10 1:57
bindum3113-May-10 1:57 
GeneralRe: WPF cascaded combo Pin
Venkatesh Mookkan13-May-10 19:50
Venkatesh Mookkan13-May-10 19:50 
Questionerror on installation of VS2010 Express Pin
arkiboys12-May-10 19:53
arkiboys12-May-10 19:53 
AnswerRe: error on installation of VS2010 Express Pin
Michel Godfroid12-May-10 20:50
Michel Godfroid12-May-10 20:50 
GeneralRe: error on installation of VS2010 Express Pin
arkiboys12-May-10 21:13
arkiboys12-May-10 21:13 
GeneralRe: error on installation of VS2010 Express Pin
Michel Godfroid12-May-10 21:16
Michel Godfroid12-May-10 21:16 
GeneralRe: error on installation of VS2010 Express Pin
arkiboys12-May-10 21:30
arkiboys12-May-10 21:30 
GeneralRe: error on installation of VS2010 Express Pin
Michel Godfroid12-May-10 21:41
Michel Godfroid12-May-10 21:41 
GeneralRe: error on installation of VS2010 Express Pin
arkiboys13-May-10 0:41
arkiboys13-May-10 0:41 
GeneralRe: error on installation of VS2010 Express Pin
Michel Godfroid13-May-10 0:49
Michel Godfroid13-May-10 0:49 
GeneralRe: error on installation of VS2010 Express Pin
#realJSOP13-May-10 3:21
mve#realJSOP13-May-10 3:21 
QuestionTreeView & Commanding Pin
Kevin Marois12-May-10 12:50
professionalKevin Marois12-May-10 12:50 
AnswerRe: TreeView & Commanding Pin
Pete O'Hanlon12-May-10 21:30
mvePete O'Hanlon12-May-10 21:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.