Click here to Skip to main content
15,880,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello, I am developing a UWP application for Windows 10.
I have embedded a textbox into a Listview, but I can't get the value of this textbox (probably due to the fact that the textbox is in a DataTemplate).
Thanks for helping me, this is my first UWA app (I was developing before in Silverlight), it's been several days since I've been looking for a solution on all forums, but I haven't found anything that works.

Here is an excerpt from my XAML:

HTML
<PivotItem Header="Favoris" Margin="0,0,0,0">
    <SemanticZoom Name="szFavoris" Height="500">
        <SemanticZoom.ZoomedInView>
            <ListView x:Name="listBoxobjFav" 
                        ItemsSource="{Binding Source={StaticResource cvsFavoris}}" 
                        BorderBrush="#FF141EE4"  Width="360" Height="495" Margin="0,10,0,0" VerticalAlignment="Top" 
                        IsItemClickEnabled="True" SelectionMode="Multiple" SelectionChanged="listBoxobjFav_SelectionChanged">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="210" />
                                <ColumnDefinition Width="80" />
                            </Grid.ColumnDefinitions>

                            <TextBlock x:Name="NameTxt" Grid.Column="0" Margin="0,0,0,0" TextWrapping="Wrap" Text="{Binding Name}" FontSize="20" Foreground="White"/>
                            <TextBox Grid.Column="1" 
                                            x:Name="QteArt" 
                                            Text="{Binding QteArt, Mode=TwoWay}" 
                                            HorizontalAlignment="Right" 
                                            FontSize="16" 
                                            Foreground="DarkGray" 
                                            InputScope="Number" 
                                            Visibility="Visible"
                                            PlaceholderText="{Binding UniteMesure}"
                                            />      
                            <!-- this is the valueof  QteArt that I want retreive in my code behind -->
                        </Grid>
                    </DataTemplate>
                </ListView.ItemTemplate>

                <ListView.GroupStyle>
                    <GroupStyle>
                        <GroupStyle.HeaderTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Key}" Foreground="CadetBlue" FontSize="18" />
                            </DataTemplate>
                        </GroupStyle.HeaderTemplate>
                    </GroupStyle>
                </ListView.GroupStyle>

                <ListView.ItemContainerStyle>
                    <Style TargetType="ListViewItem">
                        <Setter Property="FocusVisualPrimaryBrush" Value="Transparent"/>
                    </Style>
                </ListView.ItemContainerStyle>

            </ListView>
        </SemanticZoom.ZoomedInView>

        <SemanticZoom.ZoomedOutView>
            <ListView x:Name="listBoxCatFav" SelectionMode="None" Width="360" Height="500" IsItemClickEnabled="True" BorderBrush="#FF141EE4" >
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Margin="15,20,0,0" x:Name="CatTxt" Text="{Binding Group.Key}" TextWrapping="Wrap" Foreground="CadetBlue" FontSize="18"/>
                        </StackPanel>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </SemanticZoom.ZoomedOutView>
    </SemanticZoom>
</PivotItem>


What I have tried:

I have defined a UserControl, which contains the entire DataTemplate, but I am unable to embed this UserControl in the DataTemplate.
Posted
Updated 7-Apr-18 2:40am
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900