Reputation: 525
I am trying to add the text entered to a list view in UWP. However all I am seeing is button.
The picture should show what was entered, BINXXX. How do you bind textbox text to the data template for a listview? Here is my current XML.
<ListView x:Name="binListView" HorizontalAlignment="Left" Height="411" Margin="370,139,0,0" VerticalAlignment="Top" Width="388">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button Width="32" Height="32" Tag="{Binding}" Click="Delete_Item" HorizontalAlignment="Right">
<Button.Background>
<ImageBrush ImageSource="Assets/rubbish-bin.png">
</ImageBrush>
</Button.Background>
</Button>
<TextBlock Text="Whatever my textbox says" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Upvotes: 0
Views: 158
Reputation: 91
You would want to set an ItemSource property for your list view bound to a list on the c# side, which you would add to in some sort of event from the TextBox such as KeyDown or Keyup void TextBoxKeyDownEvent(object sender, KeyDowEventArgs args){ boundList.add(TextBoxNameHere.Text); }
Upvotes: 1