Search code examples
c#wpflistviewtextblockitemtemplate

how to add textboxes at the end in datatemplate


I have a ListView which gives me correct information. I want to apped at the end of each row, two TextBoxes in which user can edit, can anyone guide me?

This is the result I want to see John Smith textbox textbox.

Here is my code below:

<ListView.ItemTemplate>
    <DataTemplate>
        <Label x:Name="lblPerson">
            <Label.Content>
                <TextBlock>
                    <TextBlock.Text>
                        <MultiBinding StringFormat="{}{0}   {1}">
                            <Binding Path="FName" />
                            <Binding Path="LName" />
                         </MultiBinding>
                    </TextBlock.Text>
                </TextBlock>
            </Label.Content>
        </Label>
    </DataTemplate>
</ListView.ItemTemplate>

Solution

  • I don't know if I understand correctly what your problem is, but inside the DataTemplate you can use a StackPanel or a DockPanel and place the Label and anything else you can, something like this:

    <ListView.ItemTemplate>
    <DataTemplate>
     <StackPanel Orientation="Horizontal">
        <Label x:Name="lblPerson">
            <Label.Content>
                <TextBlock>
                    <TextBlock.Text>
                        <MultiBinding StringFormat="{}{0}   {1}">
                            <Binding Path="FName" />
                            <Binding Path="LName" />
                         </MultiBinding>
                    </TextBlock.Text>
                </TextBlock>
            </Label.Content>
        </Label>
        <TextBox Text="Something">
        <TextBox Text="{Binding SomeField}">
      </StackPanel>
    </DataTemplate>
    </ListView.ItemTemplate>
    

    Is this what you are asking? Regards