Creating a custom ItemContainerStyle for a List ItemsSource

777 views Asked by At

I'm trying to create a custom ItemContainerStyle for a ListView so that the text displayed is selectable. I'm looking to set the ItemsSource to a List<string>. If I were binding to a List<Person> (with property Name) I could do

<ListView.ItemContainerStyle>
    <Style TargetType="{x:Type ListViewItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListViewItem">
                  <StackPanel>
                    <TextBox Text="{Binding Path=Name}">
                  </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ListView.ItemContainerStyle>

How do I specify the binding for a List<T>?

1

There are 1 answers

1
Emond On BEST ANSWER

Just <TextBox Text="{Binding Mode=OneWay}"> will do.