I want to do this in xaml.
I hope somebody can help.
Thanks!
the only option I can think of is to put the text with TextTrimming set to WordEllipsis, and have a second textblock. then in onloaded check the text property to see if the last characters are ...
but i'm not even sure getting the text will retrieve text after the ellipsis is added.
one option I thought would be to create a custom ellipsis, or to to use some ontrimmed event, but they are not available.
Related
I have a property grid within which is currently a displayfield. I have been asked to make this particular field a multi-line field, so that text is wrapped around and carriage returns in the text are shown correctly.
I looked at a textareafield, but this seems to ignore readOnly: true, editable: false and methods of avoiding edits such as beforeedit: function(){return false;}.
I also tried to try and apply multiple line inserts (converting them to </br>) as part of the renderer within the displayfield , but this does not seem to work either.
What is the most efficient method of achieving this? Am I missing something simple in the API that provides the functionality I require?
I'd like to think this can be abstracted to a general case quite easily, but can provide code if deemed necessary.
EDIT:
To try and clarify my problem, I need a field that:
Cannot be edited by the user; no text bar and typing in the field.
Allows for multiple lines of text to be shown, by both word-wrap and
by carriage returns/new lines
Think of a textareafield (expands to show all its contents) crossed with a displayfield (no editing capability).
You might be looking for a textareafield with disabled set to true..
You can have new lines on the text with \n.
Hope that helps ! :)
Bear with me. I have a ComboBox (WPF) in 'autocomplete' mode.
Easy peasy right? Just set IsEditable to true.
<ComboBox
IsEditable="True"
Text="{Binding Model.TextEntered}"
ItemsSource="{Binding Model.ListWithOptions}"/>
I've got my ComboBox and it autocomplete's just perfect.
BUT when I enter the following text 'caaaaa' it changes it to 'CAaaaa'. I understand the ComboBox autocomplete's the text and match the casing. But when I want to enter caaaaa (for whatever reason) I don't want 'CAaaaa'.
Any idea to solve this?
As an alternative I would settle for (if all else fails):
When leaving the control, check if entered text doesn't match any of the options set text tolower. (as a behaviour)
Have you tried setting ShouldPreserveUserEnteredPrefix="True"? This will not alter the case that is typed into the Combobox but will still match items in the list. So in your example if you type 'ca13' it will find and select 'CA132S', but it will be displayed in the combobox as 'ca132s' (in the case that it was typed in).
A compromise in the way that the item is displayed perhaps, but it will select the correct item and allow you to type characters in either case without alteration.
Try setting IsTextSearchCaseSensitive proprty to true for the ComboBox. Not sure if this property is available in older versions of .NET
Couldn't you use an if statement to check if it matches anything in the list and if it doesn't, don't change it? Like check after each letter entered and if it then doesn't match change it back to the case that was originally entered?
Or is there a reason you want people to be able to type in something that isn't in the list? If not, couldn't you use IsTextSearchEnabled rather than IsEditable?
I am looking to bind a richtextbox's text property to an array or list of custom objects. Is this possible? I see lots of WPF related binding for richtextbox but I am doing this in winforms. My searches for an example article have not turned up anything of value yet. Figured I would ask here.
One of my database calls returns to me a list of specific instructions and I would like to stuff this entire list of instructions into the richtextbox all at once. The text property does not support an IEnumerable type so I am not sure if I can do what I am trying to do or not. I was looking for a method to fill my richtextbox without all the for looping and inserting one item at a time. I figured data binding was the best fit for that.
I've run across the same problem and have solved it by creating a custom ValueConverter. The code for it can be found here.
Basically it takes an IEnumerable in and then returns a string with a custom separator (defaults to NewLine).
I am facing a small problem using silver light . I have a RadGridView, with four columns. My second columns contains text boxes and the third column contains validation errors. If the third column contains validation errors, i want the second column background to turn red. How can i do this. I have tried binding the text box background column to a string with the desired color but that does not work. Really stuck here. Any help with be much appreciated.
Regards,
Mateen
Assuming your binding is otherwise valid, you cannot change colour by binding to a text string of a colour. The background property is of type Brush.
You need to either bind to a Brush instead, or use a brush/colour converter to return a Brush instead of a Color/string etc.
Try these links for converter examples:
http://forums.silverlight.net/p/20392/70263.aspx
http://forums.silverlight.net/p/20392/70263.aspx
You need a StringToObjectConverter found here. This class has the advantage that it has wider uses that eliminate the need to create a plethora of similar converters.
Further rather than having the bound object have a property called "Background" which tell the UI to "be red". I would be better that the Model had a property called "Status" which is an enum of the possible states the object is in.
Going further and looking at your specific requirement it would be better that your model exposed a boolean IsValid property which a converter could be applied to. See this blog on a generic BoolToValueConverter.
Need to limit character per line on multiline text box and also need to limit no of lines as well. please help.
You probably need to implement your own control inherited from TextBox - then do your own validation in a TextChanged event handler.