Question

I am developing silverlight application. I have a listbox in my application. I am doing dynamic binding with that listbox. My xaml and code behind code for dynamic binding is present in the following link. In the following link the second textblock contains the much more text than appear in the following link

How to do dynamic binding with Listbox in silverlight?

I want to resize the textblock present in the listbox as the listbox resize. For that I am referring the following two links.

http://forums.silverlight.net/forums/p/19787/518178.aspx http://forums.silverlight.net/forums/p/18918/70469.aspx#70469

In the above two links I can see that as I change the resolution of computer, the width of my listbox changes. I can see that with the code

vGrid.Width = lstbox1.ActualWidth; 

in the above link. But the width of the textblock present inside the lisbox does not change because it does not stretch to fit in the size of the listbox. Now I also want to change the width of the textblock present in the listbox as the listbox resizes. I am using windows 7 operating system. How to do that ? Can you please provide me any code or link through which I can resolve the above issue. If I am doing anything wrong then please guide me.

Was it helpful?

Solution

I found the solution. The solution is as follows

<ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
                </Style>
            </ListBox.ItemContainerStyle>

For more details you can refer the link - How to get a ListBox ItemTemplate to stretch horizontally the full width of the ListBox?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top