Heena Thakkar
Heena Thakkar

Reputation: 9

WPF Application : Textbox text selection like we do in browsers

My Application structure is attached in pictureRequiremnent

requirement 1: draw a rectagle to show area covered by mouse . here yellow rectangle

requirement 2: copy text under the yellow rectangle to clip board

  1. yellow rectangle could be in one text box or
  2. yellow rectangle could be across multiple text boxes

this yellow rectangle is drawn using mouse left button down - mouse move- mouse up.

This requirement is something similar like when we select a data in browsersample image of browserEx. here consider 3 different text boxes. I would like to copy text in blue here.

How to achieve this using WPF?

Textboxes in my case are like

<DataTemplate DataType="{x:Type mvvm:MVVMText}">
            <TextBox Name="Text" Text="{Binding Path=Text, Mode=OneWay,   UpdateSourceTrigger=PropertyChanged}" 
                    IsReadOnly="True" >
            </TextBox>
        </DataTemplate>


<Grid>

                  <ItemsControl Grid.Row="1" >

                        <ItemsControl.Template>
                            <ControlTemplate TargetType="ItemsControl">
                                <ItemsPresenter/>
                            </ControlTemplate>
                        </ItemsControl.Template>

                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                            <StackPanel Orientation="Vertical" MinWidth="550" />
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>

                      
                    </ItemsControl>
</Grid>

Upvotes: 0

Views: 43

Answers (0)

Related Questions