WPF TextBox Keep Selection

Programs like Notepad and Notepad++ have this feature where when you want to find words, you bring up the Find menu and enter your query and start searching. The interesting part in this is that when you're searching for the words, the find window
doesn't loose focus and the user can use the 'ENTER' key to keep scrolling through all the words. The end result is that the text is selected and highlighted and still has the focus on the window. 
For me, I've got a Find form and I'm trying to do exactly hat Notepad does when it finds words. It shouldn't loose focus on the find window so the user can keep hitting the 'ENTER' key while going through the textbox for words. I can't seem to get this to
work mainly because I'm using Textbox.Select(start, end) and right after that TextBox.Focus. This is the only way I can select Text in the TextBox. To open the Form I make it an owner form through the Main form.
Is it possible to do what Notepad is doing in terms of highlighting the text without loosing the focus on the form without needing to rewrite a Custom TextBox? I don't intend to use a RichTextBox and I'm aware of the IsInactiveSelectionHighlightEnabled.
MessageBox.Show("Hey You!")

Hi,
Thank you for visiting the MSDN forum.
I’m afraid that it is not the correct forum about this issue, since this forum is to discuss Windows Forms General. Your issue is related to wpf, and your question would be moved to the wpf forum.
Thanks for your understanding.
Regards,
Edward
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.

Similar Messages

  • Trackpad keeps selecting, anyone an idea how to fix this?

    The trackpad of my macbookair (2012) keeps selecting. On the screen appear squares and while using applications it keeps selecting...
    the problem started suddenly, while I was working in Word, no clear cause...
    Does anyone have an idea how to fix this? Thanx

    Check your battery's condition. An aging battery can fail in a manner causing it to swell, exerting pressure on the trackpad from underneath.
    Jumpy trackpad operation also can be caused by third party power adapters, among other things. Read Portables and Magic Trackpad: Jumpy or erratic trackpad operation

  • Win 8/8.1 - used tiles keep selected

    Hi,
    My HP notebook is the 8470w.
    I've recently found this issue and even after 2 clean installations of win8 and 8.1 upgrade, during its updates, I kept getting the same problem: when I start an app/program the related tiles keep selected (as in the picture) as well as other menu settings.
    Any of you had the same isse and/or know how to fix it?
    (Which OS would you recommend for this laptop between w7 and w8/8.1?)
    Thanks!

    Hi,
    My HP notebook is the 8470w.
    I've recently found this issue and even after 2 clean installations of win8 and 8.1 upgrade, during its updates, I kept getting the same problem: when I start an app/program the related tiles keep selected (as in the picture) as well as other menu settings.
    Any of you had the same isse and/or know how to fix it?
    (Which OS would you recommend for this laptop between w7 and w8/8.1?)
    Thanks!

  • Create a Behavior for Calendar in a WPF UserControl to Select and Unselect dates with one click

    Hi to everyone,
    I am developing an application with a WPF Client. This Client use the MVVM pattern.
    In an UserControl the application must show some Calendars, so the user can select one or multiple dates.
    For that use, I should implement some behavior that allows the user click once in a date and that date is selected (what already exists in .NET Framework) and with another click in the same date, that date is now unselected.
    I've already made some searches and can't find anything useful.
    This kind of behavior it is possible to implement in the Calendar Control? How exactly I do this?
    Thanks for reading/helping
    Rafael Duarte

    You should be able to accomplish this by modifying the default template of the CalendarDayButtonStyle of the Calendar and handling the PreviewMouseLeftButtonDown of the Grid in the default template. Here is an example:
    <Window.Resources>
    <Style x:Key="CalendarDayButtonStyle1" TargetType="{x:Type CalendarDayButton}">
    <Setter Property="MinWidth" Value="5"/>
    <Setter Property="MinHeight" Value="5"/>
    <Setter Property="FontSize" Value="10"/>
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>
    <Setter Property="Template">
    <Setter.Value>
    <ControlTemplate TargetType="{x:Type CalendarDayButton}">
    <Grid Background="Transparent" PreviewMouseLeftButtonDown="Grid_PreviewMouseLeftButtonDown">
    <VisualStateManager.VisualStateGroups>
    <VisualStateGroup x:Name="CommonStates">
    <VisualStateGroup.Transitions>
    <VisualTransition GeneratedDuration="0:0:0.1"/>
    </VisualStateGroup.Transitions>
    <VisualState x:Name="Normal"/>
    <VisualState x:Name="MouseOver">
    <Storyboard>
    <DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="HighlightBackground"/>
    </Storyboard>
    </VisualState>
    <VisualState x:Name="Pressed">
    <Storyboard>
    <DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="HighlightBackground"/>
    </Storyboard>
    </VisualState>
    <VisualState x:Name="Disabled">
    <Storyboard>
    <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="HighlightBackground"/>
    <DoubleAnimation Duration="0" To=".35" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="NormalText"/>
    </Storyboard>
    </VisualState>
    </VisualStateGroup>
    <VisualStateGroup x:Name="SelectionStates">
    <VisualStateGroup.Transitions>
    <VisualTransition GeneratedDuration="0"/>
    </VisualStateGroup.Transitions>
    <VisualState x:Name="Unselected"/>
    <VisualState x:Name="Selected">
    <Storyboard>
    <DoubleAnimation Duration="0" To=".75" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="SelectedBackground"/>
    </Storyboard>
    </VisualState>
    </VisualStateGroup>
    <VisualStateGroup x:Name="CalendarButtonFocusStates">
    <VisualStateGroup.Transitions>
    <VisualTransition GeneratedDuration="0"/>
    </VisualStateGroup.Transitions>
    <!--<VisualState x:Name="CalendarButtonFocused">
    <Storyboard>
    <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DayButtonFocusVisual">
    <DiscreteObjectKeyFrame KeyTime="0">
    <DiscreteObjectKeyFrame.Value>
    <Visibility>Visible</Visibility>
    </DiscreteObjectKeyFrame.Value>
    </DiscreteObjectKeyFrame>
    </ObjectAnimationUsingKeyFrames>
    </Storyboard>
    </VisualState>-->
    <!-- <VisualState x:Name="CalendarButtonUnfocused">
    <Storyboard>
    <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DayButtonFocusVisual">
    <DiscreteObjectKeyFrame KeyTime="0">
    <DiscreteObjectKeyFrame.Value>
    <Visibility>Collapsed</Visibility>
    </DiscreteObjectKeyFrame.Value>
    </DiscreteObjectKeyFrame>
    </ObjectAnimationUsingKeyFrames>
    </Storyboard>
    </VisualState>-->
    </VisualStateGroup>
    <VisualStateGroup x:Name="ActiveStates">
    <VisualStateGroup.Transitions>
    <VisualTransition GeneratedDuration="0"/>
    </VisualStateGroup.Transitions>
    <VisualState x:Name="Active"/>
    <VisualState x:Name="Inactive">
    <Storyboard>
    <ColorAnimation Duration="0" To="#FF777777" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="NormalText"/>
    </Storyboard>
    </VisualState>
    </VisualStateGroup>
    <VisualStateGroup x:Name="DayStates">
    <VisualStateGroup.Transitions>
    <VisualTransition GeneratedDuration="0"/>
    </VisualStateGroup.Transitions>
    <VisualState x:Name="RegularDay"/>
    <VisualState x:Name="Today">
    <Storyboard>
    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="TodayBackground"/>
    <ColorAnimation Duration="0" To="#FFFFFFFF" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="NormalText"/>
    </Storyboard>
    </VisualState>
    </VisualStateGroup>
    <VisualStateGroup x:Name="BlackoutDayStates">
    <VisualStateGroup.Transitions>
    <VisualTransition GeneratedDuration="0"/>
    </VisualStateGroup.Transitions>
    <VisualState x:Name="NormalDay"/>
    <VisualState x:Name="BlackoutDay">
    <Storyboard>
    <DoubleAnimation Duration="0" To=".2" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Blackout"/>
    </Storyboard>
    </VisualState>
    </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    <Rectangle x:Name="TodayBackground" Fill="#FFAAAAAA" Opacity="0" RadiusY="1" RadiusX="1"/>
    <Rectangle x:Name="SelectedBackground" Fill="#FFBADDE9" Opacity="0" RadiusY="1" RadiusX="1"/>
    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"/>
    <Rectangle x:Name="HighlightBackground" Fill="#FFBADDE9" Opacity="0" RadiusY="1" RadiusX="1"/>
    <ContentPresenter x:Name="NormalText" TextElement.Foreground="#FF333333" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="5,1,5,1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
    <Path x:Name="Blackout" Data="M8.1772461,11.029181 L10.433105,11.029181 L11.700684,12.801641 L12.973633,11.029181 L15.191895,11.029181 L12.844727,13.999395 L15.21875,17.060919 L12.962891,17.060919 L11.673828,15.256231 L10.352539,17.060919 L8.1396484,17.060919 L10.519043,14.042364 z" Fill="#FF000000" HorizontalAlignment="Stretch" Margin="3" Opacity="0" RenderTransformOrigin="0.5,0.5" Stretch="Fill" VerticalAlignment="Stretch"/>
    <Rectangle x:Name="DayButtonFocusVisual" IsHitTestVisible="false" RadiusY="1" RadiusX="1" Stroke="#FF45D6FA" Visibility="Collapsed"/>
    </Grid>
    <ControlTemplate.Triggers>
    <MultiTrigger>
    <MultiTrigger.Conditions>
    <Condition Property="IsSelected" Value="True"/>
    <Condition Property="IsFocused" Value="True"/>
    </MultiTrigger.Conditions>
    <Setter Property="Visibility" TargetName="DayButtonFocusVisual" Value="Visible"/>
    </MultiTrigger>
    </ControlTemplate.Triggers>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>
    </Window.Resources>
    <Calendar x:Name="cal" CalendarDayButtonStyle="{DynamicResource CalendarDayButtonStyle1}" />
    private void Grid_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) {
    Grid grid = sender as Grid;
    CalendarDayButton button = FindParent<CalendarDayButton>(grid);
    if (button.IsSelected) {
    Calendar cal = FindParent<Calendar>(button);
    if (cal.SelectedDate.HasValue) {
    cal.SelectedDates.Remove(cal.SelectedDate.Value);
    e.Handled = true;
    Hope that helps.
    Please remember to mark helpful posts as answer and/or helpful.

  • How do you keep selected colors with Live Paint Bucket?

    I am always having to re-select the colors for fill and stroke each time I use the Paint Bucket.  This is tedious. There must be a way to keep the selection...

    Not sure what the "Live Paint Bucket" is, but if you are working in Premiere's Titler, and have constant Stroke and Fills, you can easily create and Save a Style, so that the colors and attributes will be constant, Title through Title. The Style will even set your font, and its size, for reuse.
    Another method would be to Save the Title, and use it in multiple Projects, just changing the Text, as is required.
    Now, if you are talking about something else, please point me in the correct direction.
    Good luck,
    Hunt

  • Keep selection on table refresh

    Hi,
    I have a selectOneChoice table based upon a view. I'm trying to update the DB values for the selected row in the background (i.e. change of column value or so) and then want to refresh the table with keeping the row selected.
    It works, when I have no selection state assigned to the table as table property (selectionState="#{bindings.MyView1.collectionModel.selectedRow}"). But then there is initially no row (i.e. the first row) selected - that's bad too!
    Is there any way to refresh a single row in a table or to keep somehow the selected one during refresh?
    Thank you very much!
    Sebastian

    Frantz,
    Sure you can.
    1. Set "selection cardinality" of corresponding node to 0..1 or 0..n rather 1..1 or 1..n
    2. Set "initialize lead selection" of corresponding node to false.
    Valery Silaev
    EPAM Systems
    http://www.NetWeaverTeam.com

  • Moving an entire selection in the timeline, keeping selection in tact?

    Hello, is it possible to make a selection and that lock the length of the selection in place while you move it to another location on the timeline?
    Or if not, is it possible to set a marker range and lock that in place then drag the marker range to another location keeping it's length in tact?

    If you group a selection of clips, they are locked in relative time. So if you pick the group up and drag it somewhere else, all those relationships remain intact.
    You make the selection by Ctrl-clicking on the clips you want to group, and then right-click and select the group option, or simply hit Ctrl-G. You also have the choice of locking the group in absolute place, or unlocking it and keeping the clips in relative place.

  • Shuttle Control: Keep selection after page submit

    Hi @all,
    I tried out Carl's shuttle control.. GREAT work!
    Now I have a question: Is it possible to recall the page (after hitting a button) and keep the control with the selections/moves made without writing them into the database?
    Thank you!
    Best regards
    Steven

    Hello All,
    After a long think, I've decided to separate this into a 2 applications.
    But still would have liked to hear from the community how I could have over come this.
    Maybe have 2 application, with one redirecting to the other after login?
    Thanks Jan

  • Update keeps selecting a removable drive.

    Update keeps trying to select a removable drive to download to. How do I get the download to go to the C drive ?

    The most common cause of this problem:
    At one time, there was a removable disk. My Pictures was moved there. This is not an ordinary folder, software installed may need to refer to it (even if there are no pictures at the moment).
    Simplest solution:
    Stick back some removable disk until the job is done.

  • Update textbox by selecting a different row

    It's like a messaging app so when you click on the selected
    message title, the text shows in the textbox. Well, I've got a nice
    list of message titles but what is the trick for updating the
    textbox to reflect the message chosen? I can do this with separate
    pages but that seems silly. I imagine this is something to do with
    an onclick handler but can someone point me to an example?
    Thanks!

    Hopefully, this will get you started:
    <head>
    <title>Untitled</title>
    <style type="text/css">
    .message-text-hidden{
    display: none;
    </style>
    <script type="text/javascript">
    function display(anElement){
    var number = anElement.id.split('-')[1];
    document.getElementById('message-text').value =
    document.getElementById('message-' + number).innerHTML;
    </script>
    </head>
    <body>
    <div id="title-1" class="message-title"
    onclick="display(this)">All you need to know about
    investing.</div>
    <div id="message-1" class="message-text-hidden">Start
    early</div>
    <input type="text" id="message-text"></input>
    </body>

  • [WPF] TextBox and String Format Hour:Minutes

    Hi,
    I would set the string format in a TextBox that it is binding with a Date.
    For example, if I have 01/04/2015 16:11,
    1) I would show only 16:11
    2) When the user modifies the hour must respect the format hh:mm
    Thanks.

    Please close your previous threads by marking helpful posts as answer before you start a new one.
    If the source property is a DateTime you could use the StringFormat property of the binding:
    <TextBox Text="{Binding Date, StringFormat=hh:mm}"/>
    >>When the user modifies the hour must respect the format hh:mm
    A TextBox is only a textBox where the user can type in some text. If you want to restrict the format of the input you could use a masked TextBox. There is no such control built-in into WPF but the WPF Toolkit contains one that you can use:
    https://wpftoolkit.codeplex.com/wikipage?title=MaskedTextBox
    Please remember to mark helpful posts as answer to close your threads and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

  • Keep selected row after calling TF

    Hi,
    I'm using jdeveloper 11.1.2.3.0
    This is my case:
    In one TF I have a fragment with a table.
    In each row of this table I have an edit button to edit the row.
    when I select a row and click on the edit button it's calling to another TF with edit form.
    When I return back from the another TF i'm doing executeQeury to the view in the first TF,
    so the user will be able to see the changes that were done in the table.
    Then I see the iterator standing on the first row of the table.
    I would like the iterator to keep the selected row that was before calling the edit TF.
    I could I do that?
    Thanks

    When I return back from the another TF i'm doing executeQeury to the view in the first TF,
    As you said you are doing executeQuery(), so the row currency changed to first row. While returning from the taskflow you might have some method to execute this. In the same method you need to change the row currency to previous key.
    DCIteratorBinding iter = (DCIteratorBinding)getBindings().get("EmpUVO1Iterator");
    iter.executeQuery();     
    ADFContext aDFContext = ADFContext.getCurrent();
    Key key = (Key)aDFContext.getSessionScope().get("key");
    System.out.println("key "+key);
    ViewObjectImpl vo = (ViewObjectImpl)iter.getViewObject();
    Row[] row = vo.findByKey(key,1);
    vo.setCurrentRow(row[0]);

  • How to Put Date in a Textbox after Select

    Hi, DWMX. How do i put todays date into a text box after
    selecting an item from a ListBox. ie I want to change the staus in
    the Listbox and have the StatusChangedOn Text box filled
    automatically so it gets saved on submit.. I guess it's a bit of
    java which i don;t know any of. I am using VBScript for the server
    code. Thanks. Dave(UK)

    Dave
    If this is being a saved to a database simple set the default
    value of the
    database field to record the server time when the entry is
    made. In Access
    this is Date(), in msSQL it is getDate()
    Paul Whitham
    Certified Dreamweaver MX2004 Professional
    Adobe Community Expert - Dreamweaver
    Valleybiz Internet Design
    www.valleybiz.net
    "Dave(UK)" <[email protected]> wrote in
    message
    news:e5v91r$olj$[email protected]..
    > Hi, DWMX. How do i put todays date into a text box after
    selecting an
    > item
    > from a ListBox. ie I want to change the staus in the
    Listbox and have the
    > StatusChangedOn Text box filled automatically so it gets
    saved on submit..
    > I
    > guess it's a bit of java which i don;t know any of. I am
    using VBScript
    > for
    > the server code. Thanks. Dave(UK)
    >

  • Mail keeps selecting text in the To & Subject fields as I type

    Since upgrading to Leopard (and by upgrade doing a clean install and then running migration assistance) and the 10.5.1 update Mail is acting very strange. When ever I try to type in the To, CC, BCC, Reply To or the Subject Mail immediately selects the texts and 9 times out of 10 will not search the Address Book. For example, I try to type the name "James" but after typing the "J" Mail highlights it so it gets overwritten by the "a" which gets overwritten by the "m" and so on. If am fast enough it will complete "James" and search the Address Book. Or if there is not an entry it will just highlight "James". This behavior makes it impossible to type a new email address or even to write a subject and extremely difficult to pull names automatically from the Address Book. It is one of the weirdest things I have ever seen and I haven't been able to figure out a way to make it stop. Holding down the right arrow key while typing almost made it work but not quite. It seems to delay the selection process by half a second or so but not stop it. Anyone else experience this bizarre behavior or have any idea how to fix it?

    While I take some comfort in the fact that I am not the only one experiencing this problem, it really ***** that I have not come across a really effective solution. But I do have an update that might help but only slightly.
    So I started messing around with mail since this whole thing started. What I found is removing the "com.apple.mail.plist" file from ~\library\preferences seemed to mostly resolve this problem in the To & Cc address fields. Problems still occurs as described in the Bcc & Subject fields. I initially thought removing this file (and this is after backing up the mail folder, the plist file & and my messages to MailSteward just in case) had completely resolved the issue but no suck luck. Of course, I had to re-add all my accounts. And of course Mail "forgot" all the messages that were originally part of each account even though they were all still in the Mail folder. This is a pet peeve of mine. Mail won't import it's on mail content formats unless you manually open each email and tell it to move to a folder in Mail. But that's another topic.
    After resetting up Mail I can normally type in the To & Cc fields and have it search the address book or previous messages. However just typing and pausing between letters causes it to have the problem again about 50% of the time. That is for the To & Cc fields. For the Bcc field I have to do the super fast typing to get it to do the search. So if I am actually fast enough to type "james" it will find it. If am slow and type "jam" the problem returns. If typing a new e-mail not in my address book or a previous e-mail forget about it. Type it somewhere else and then copy and paste. Basically it seems as though it will work if I can somehow get the field to start the address book search when typing. I've tested it a few times and once the field is able to pull up the search results (i.e. pasting a name that it should be able to find) it seems to work fine from that point on. Meaning you can then continue to normally add names to field or make changes to what was previously typed. But it is tricky at best to get it to work in the first place. The Subject line is still a mess and I have resorted to typing the subject in the body of the e-mail and cutting and pasting into the Subject line.
    I tested this several times, removing and then restoring the original plist. I hope I have made a clear summary as to my experiences. Basically the original plist file had the original nearly unsolvable problem. When it was removed and Mail recreated it, I set up a new main account and the To & Cc fields were somewhat more forgiving though still have the problem about half the time. While the Bcc field has the problem 99% of the time and so far the Subject field still has it 100%.
    For the record I use the Widescreen and HTTPMail plugins. But I am convinced these are not the issue because I did not re-add them to Mail until I had tested this issue with my regular pop account. Once I was satisfied with the results I installed these plugins and there was no difference in the way the program reacted. Also I use SpamSieve but since it only activates when I have new Mail this did not seem to make a difference as I have tried it with it off and on with the same results. This is the most annoying problem I have experienced on a Mac. It has me contemplating switching back to Entourage.

  • IPhoto keeps selecting the "Last Import" tab on the left hand side.

    Whenever I'm looking at photos in iPhoto, it will randomly switch to the "Last Import" tab on the left hand side so that I've viewing photos from my last import. It doesn't matter if I'm editing photos, or just looking through events, every 5 minutes or so, iPhoto switching to the Last Import tab. Any one know how to fix this? I've checked iPhoto for updates - it seems mine is up to date.

    Go to your Pictures Folder and find the iPhoto Library there. Right (or Control-) Click on the icon and select 'Show Package Contents'. A finder window will open with the Library exposed.
    Look there for a Folder called 'Auto Import'.
    Drag anything inside to the desktop.
    Relaunch iPhoto.

Maybe you are looking for

  • Report performance problems on htmldb 1.6

    Hello everybody, I'm not a guru in both pl-sql and htmldb and I'm having slow performances on two queries, that are similar, so I think the root of the problem is the same..here they are: This query populates a select list and takes about 2 minutes:

  • Late 2007 15" MBP Very slow after upgrading to Mavericks

    Hi guys, this is my first post here. I look forward to learn and help others. The reason of this post is, as outlined in the title, slow paerformance of my computer after upgrading to Mavericks. It was kinda slow from before but this time it's almost

  • Graphics Card not working as it should?

    Hi. i bought a pavilion dv7-4165dx laptop so i could play my favorite games on it, but today when i tried to run need for speed carbon with maximum settings the game started to lag a lot, then i apply medium settings and it still did the same thing u

  • TCODE-to view the content of setuo table

    Hi Experts, Can anyone let me know is there any TCODE where we can view the content of setup table Regards, Meera

  • Alpha Tween not working on ScrollPane gallery?

    Hello i have a problem with my as3 working on normal movieclips, but not on the gallery, the site  works by loading an external swf file with the UILoader, the swf that is  loaded is a ScrollPane that loads a Movieclip. The script i use: import fl.tr