I am creating a control that displays a hex value (For example FFAA-CA10-56D7) . Right now the value consists of images. The value of the control looks like:
For a read only control I have no problems. I am able to place the appropriate images according to the value. So if I have to set the value to FF for example I will iterate through the characters on the string and then place the corresponding image.
Now the problem is with read-write controls. It will be nice if I could use the same font. Right now I append images as the user types values. But it is not friendly. What if the user wants to select 3 characters by dragging the mouse?. Or how could I perform the shift+arrow key combination that will select multiple characters.
So in short I will like to keep the same look and feel of the control and I do not want to replace the images for a textbox. What approach do you guys recommend so that I can keep the same look and feel.
Things I have tried:
I tried to create my custom font from those png's. But haven't been successful on finding the right program that will enable me to create a font from png images.
I would do this by using a custom ListBox with a Horizontal StackPanel as its ItemPanelTemplate, and its ItemsSource would be a list of char. then you could provide an appropiate DataTemplate containing the corresponding images (dependending on char value, maybe using DataTriggers). ListBox has Multiselection, so you should have no problem in imitating the Text Selection behavior of a TextBox, and by having a List of char as the ItemsSouce you can also allow Copying (by doing your own implementation of EditCommands.Copy in your ListBox.
Edit: This is one of those cases in which you will definitely want to implement your own Custom Control
Related
I added a listbox control to log entries but I want the entries to have a date in the right side. Apparently, I'm able to only align it one side and not able to have this text on both the side. I was wondering if it is possible. Here's a photoshopped image to describe what I need. The right side date doesn't actually turn up. I added that through photoshop but its exactly what I need.
I would like to suggest you to use ListView instead of Listbox. You can show your list with multiple columns in detail view. You can also align column value, Hide header using HeaderStyle property.
If you don't want to use ListView control and want to use ListBox. then you have three options to do that.
You can draw item using OwnerDraw method.
You can add label to the ListBox. but, it creates lot of problems when you are trying to scroll items.
Set the listbox font Courier New and use String.PadRight or String.PadLeft to place space between two item. But, in this method the item will be return with space. Here you need to process to separate that field.
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 am working on an autocomplete search box in a Windows 8 app. The box needs to allow typing and then have text show up beyond the cursor, in a different color.
Our current approach is to layer one textbox on top of the other, but it seems to me like there could be a better way.
On iOS/Mac I could do this with an NSAttributedString, but I don't know if an equivalent like that exists on WinRT/.NET.
(For those that don't know, an NSAttributedString is a string that allows you to set attributes like color or size on different sections)
I usually approach that by auto-completing the text and marking the completed part as selected, so when the user continues typing - the selected part gets replaced by typed in characters. I doubt this will give you the specific visual effect - with no highlight, but changed text color, but I'd claim this is the only feasible and reliable solution.
I'm attempting to make a command prompt clone in C# so I can get familiar with using IO. However, instead of just one text body, I created two text boxes (one for the command and another for the "parameters") and a rich text box to view the result of the commands. It may sound confusing and the title may be misleading, but I didn't know how else to word it. Anyway, my question is- how do you make only the current line editable and the rest read-only? And how would I be able to combine the commands and parameters in the two text boxes so I wouldn't need two separate text boxes? I have spent 6 days trying to figure out the logic to implement this but I got nothing.
Here's a picture of the form:
And here's what I want to make it similar to:
I'm not sure if you can do that, but if it was me, and this was a "get it done now" situation (and this is just off the top of my head), I would create a user control to contain the "screen". This user control would have the RTF or list box as the top, and a textbox flush under it.
I would remove the borders and wrap both these controls in a panel that has borders. This would simulate a single control.
The textbox would check for the enter key in one of the key-press events, and the control itself would have events that could be handled by the parent control.
This may be hacky, but it would probably be what I'd do in a last minute situation.
Oh as far as the command and parameter stuff, if you read the textbox as a single value, then split the string into an List or array, you could then define a switch or some other conditional code that would know what to do with parameters (index 1+), based on the value of the first item/index.
I need to design a kind of templating system for text: the user enters a piece of text and types some special markers like (**) inside the text that tell the software that the text (**) will need to be changed to some other content.
What I would like to do, is displaying the user the list of fields that need to be changes so that the user can insert the proper data.
I was thinking about doing that displaying all the text (in a text box) and substitute the (**) chars with a textbox so that the user can enter the text. Is there a way to do that? What do you think of this approach? Do you have better ideas? The point is that I would like to show the user the context in which the substitution takes place.
Thanks.
Why not scan the text and generate textboxes on the fly?
Your code would display the templated text, scan it and then, per templated variable it finds, generate 1 textbox. You list those textboxes, one per line, below the text and as soon as the contents in one textbox change, you update the text so that the user sees what this will look like.