I made a virtual keyboard in xaml c# using WPF. Its totally working and great. However I would like to add a few quality of life things if possible. Is there a method of having it take keyboard input while in the background and your primary application is say notepad. The virtual keyboard highlights keys as they are pressed is why this is important.
Barring this is there a way to make the text in a textblock selectable for copy paste (I can track what was typed and post it in one, BUT THE TEXT SHOULD NOT BE DIRECTLY ALTERABLE!!!!, much like a website)
I'd also like to know if there is a way to have the curser default to a textbox rather than having to click it.
You should use low level hooks in your app for show pressed keys.
See a code sample here.
I can't help with the keyboard part, but there are a couple of ways to do the copy only text:
Barring this is there a way to make
the text in a textblock selectable for
copy paste (I can track what was typed
and post it in one, BUT THE TEXT
SHOULD NOT BE DIRECTLY ALTERABLE!!!!,
much like a website)
For one, you could just create a TextBox that is marked with IsReadOnly=true. You could also display a FlowDocument with a textblock on the inside.
As for defaulting (I'm assuming you mean focus), this might help:
http://msdn.microsoft.com/en-us/library/aa969768.aspx
Related
Is there any library available for Windows Phone with the tags in a search box feature? So if I start typing age, the search box should predict agent and agent smith etc and on tapping the predicted results, the search box gets filled with the tags (example image attached). Handling events like, backkeypress highlights the tag and another backkeypress removes the tag etc. Predicting results is easy, what I am looking for is all the events handling for search box with tags. Any free/paid library for the same?
There are a few AutoCompleteBoxes (Telerik, Windows Phone Toolkit), but the just work for one item. If you want more items, you need to create the control by yourself.
A lot of third party controls are available but you should prefer to write your own control. I used http://wpfactb.codeplex.com/releases/view/42340 control but you have to customized it and bugs are there to be fixed .
So I will suggest you to get hint from this and write your own control.
For something as specialized as this, I would write it myself. And XAML suits really well for such tasks.
One horizontal stackpanel with custom styled buttons being added, and one LongListSelector for the results.
This is very simple to implement.
Set the InputScope in your textbox.
On typing , you will get the possible result.
When you tap on the respective suggestion, you will get the value.
Create a Grid or Stackpanel and create a ellipse which should hold the tag value.
On tap of the value, add the value inside the created ellipse.
I believe am in need of creating custom RichTextBox in C#. One kind of like that:
I admit it might not even have to be RichTextBox, but after some research I decided it's gonna be the easiest way. Functionality I need are icons at each row, checkboxes and text formatting. My program will process each line of the text and mark lines that are correct, incorrect, and strike out lines not necessary in further work, while showing line that's currently processed and allowing user to edit some lines freely (here: lines before Around 3 000 won't be editable, but those under the line will).
What's the problem then? I have no idea how to get it done. I've seen tutorial on how to make single-line textBox with icon or checkbox nearby, but I have no idea how to make both, and for multiline textBox (so I could freely scroll and everything would work fluently). I've read some questions on SO as well, but neither helped me.
I just don't know how to get started, I realize it won't be 5 min work, but I'm willing to do it. Until now I've been only able to create custom control deriving from RichTextBox, but I have no idea which methods and how to override. Any help appreciated.
Try to use WebBrowser control instead RichTextBox.
You can add CheckBoxes and editable content by setting a correct HTML code to it.
Set each TextBox or CheckBoxes ids and use GetElementsByTagName or GetElementById to access inner elements to get or set its attributes or values.
So im making a WPF project where one of my windows has to let the user see a text. Select parts of this text for being put into an array of strings and no more than that. So he/she musnt be able to edit anything in the text only highlight parts and then click on a button. What WPF control would be smart to use for this?
I'd probably just use TextBox with IsReadOnly set. The various selection properties are all you need after that.
I have a form which has a Combo Box Control. I have selected the drop down style property to DropDown. I have also set the DropDown Width to 250.
I have set the auto complete mode to suggest and the auto complete source to listitems.
it works absolutely fine when i click on the drop down. but when i type in somethin, the auto complete mode activates a drop down which has a small width.
any help appreciate.
i wanna know how to increase the width of the auto complete drop down via code so that the list items are viewed properly.
I am using C#
Yes, this is by design. ComboBox uses the SHAutoComplete API function to implement the autocomplete feature. Note the declaration, the function takes a handle to the text box portion of the ComboBox. As such, it has no idea that it is actually providing autocomplete info for a ComboBox instead of a TextBox. Accordingly, there is nothing it can do to compensate for the non-standard dropdown width you use.
Well, that explains why it doesn't work. Fixing it is technically possible but quite ugly. You would have to run code in the KeyUp event and use EnumTheadWindows() to find the autocomplete window handle. Then you can use SetWindowPos() to make it larger. There is already code similar to this in ComboBox.cs (AutoCompleteDropDownFinder.FindDropDowns), use the Reference Source or Reflector to help you get this right. Good luck!
EDIT:
I removed my first suggestion to come up with a new link:
Actually its possible to control the width of the Autocomplete dropdown box, but its a little bit tricky and involves using win API extensively ...
Combobox too small when doing Suggest
Maybe this article that I wrote on Codeproject might help you in relation to the combo-dropdown boxes and a way that I hacked this...
Im trying to emulate a 'find as you type' function like that of the address bar ("awesome bar") in FireFox. I want a suggestion box to appear below a textbox, and the suggestion box contains strings that contain what is in the textbox. I looked at the autocomplete feature of a normal WinForms textbox, but it seems to only search the beginning of the strings.
Has anyone here built or have experience with implementing something like this?
edit:
Some clarification- It is a WinForms project.
It needs to search inside a string, not just the beginning (which is what a normal textbox does if i recall correctly). And the suggestions should be displayed in a popup like a textbox autocomplete.
You need to handle the TextChanged event for your text entry field, and when the text changes, start a new thread running that will apply the new search. If the text changes before you get your results back, just kill the thread. If the thread returns results in time, display them.
You can get slightly more advanced (e.g. wait for a short time after the text changes so that the user can type a word without you triggering off loads of useless threads) but essentially that's it.
There was a discussion earlier on this topic where the author concluded that you are better off doing the whole thing yourself.
How can I dynamically change auto complete entries in a C# combobox or textbox?
I did something vaguely similar, but more like the iTunesĀ® search box than the Awesomebar. My control used the textbox to actively filter a grid; so it wasn't for autocompletion.
...but... basically I had a DataView of all eligible items, whenever the TextBox's Text changed I'd update the Filter to hide all non-matching items. It worked well and might suit your needs for filtering the data--but not sure how to go about using it as an AutoComplete source for the textbox.
I have done such a thing for an app of mine not too much time ago.
What I did is make my search function in a new thread, so every time I typed a new letter, it called the search function in another thread, so I could keep on typing.
I can post some code if you need, but this should be enough to get you started. :)
Hemmed and hawed about deleting this after I noticed the OP edit mentioned winforms, but I think it'll be useful to anyone who comes here looking for the same but for asp.net apps.
Just because nobody has mentioned it yet, for a webforms app you absolutely want to do this with ajax (.net controls or pure JS, your choice). The feature is often called "autocomplete" and the one thing you don't want it to be breaking the seamlessness by making server round trips at the page level.
I suggest you look at this and this.
I've used Search As You Type in C# and How do I make a Textbox Postback on KeyUp?
Basically you use the keyup action to call a postback thats attached to the trigger to the update panel. then you do your update in the textbox_changed event with the dataview or whatever your backend looks like.