There is something like this:

<Page x:Class="Project1.TestPage" 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" xmlns:i="using:Microsoft.Xaml.Interactivity" xmlns:core="using:Microsoft.Xaml.Interactions.Core" xmlns:media="using:Microsoft.Xaml.Interactions.Media" mc:Ignorable="d" Background="#f4f4f4" RequestedTheme="Light"> <Page.Resources> <!-- Π¨Π°Π±Π»ΠΎΠ½ элСмСнта списка --> <DataTemplate x:Key="List_Item"> <Border Background="#fff"> <!-- TextBox'Ρ‹, Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Ρ… Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ ΠΏΠΎΠ»ΡƒΡ‡ΠΈΡ‚ΡŒ --> <TextBox PlaceholderText="{Binding value}"/> </Border> </DataTemplate> </Page.Resources> <Grid> <!-- Бписок, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ Π±ΡƒΠ΄Π΅ΠΌ Ρ‚ΠΈΡ€Π°ΠΆΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ --> <ListBox x:Name="MyList" ItemTemplate="{StaticResource List_Item}" Background="Transparent"/> </Grid> </Page> 

After some calculations in behind-code we get:

 MyList.ItemsSource = new object[] { new {value = "One"}, new {value = "Two"}, new {value = "Three"} }; 

The number of elements is not known in advance.
My problem is that I don’t know how to get user input in a TextBox . I tried:

 foreach (var item in MyList.Items) {} 

but the item is a binding object, not a ListBoxItem .
Assigning the name x:Name TextBox 's effect also does not give.

PS The second mini-question: in the process of work, it seemed to me that ListBox not too good for such a task, you need to disable many actions and styles by default. Is there a control to which you can simply pass the markup and ItemSource , after which it simply replicates it (markup), thereby implementing the list of elements, without a functional like selection and so on?

    1 answer 1

    Found a solution to this issue. We rewrite a little TextBox :

     <TextBox Text="{Binding value, Mode=TwoWay}" PlaceholderText="{Binding p_value}"/> 

    And now at any time in the value is the value specified by the user.