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?