In Silverlight, what structures, aside of the ListBox, can be used for binding?

Posted by Aidenn on Stack Overflow See other posts from Stack Overflow or by Aidenn
Published on 2010-04-18T11:31:58Z Indexed on 2010/04/18 11:33 UTC
Read the original article Hit count: 172

Filed under:

I need to simply provide the content of a property to a custom User Control in Silverlight.

My control is something like this:

<UserControl x:Class="SilverlightApplication.Header"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignWidth="300" d:DesignHeight="120">

<Grid x:Name="Header_Layout">
    <StackPanel x:Name="hiHeaderContent" Width="Auto" Margin="73,8,8,8">
        <TextBlock x:Name="User:" Text="{Binding name}" />
</StackPanel>
</Grid>

I try to use this User Control from another control where I try to pass the parameter "name" to the previous UserControl ("Header").

I don't need to create a "ListBox" as I will only have 1 header, so I try to avoid doing:

            <ListBox x:Name="HeaderListBox" Grid.Row="0">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <SilverlightApplication:Header/>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

in order to send the "User" account using:

HeaderListBox.ItemsSource = name;

Is there any other structure I can use instead of the ListBox to pass the parameter just once? It won't be a list, it's just a header...

Thank you!

© Stack Overflow or respective owner

Related posts about Silverlight