Hello there, I need some help.
I develop a .net core wpf (mvvm) application. I have a view with a XamComboEditor. I use a relatively dark background and therefore it is absolutely necessary to change the color of the blinking cursor of the underlying textbox of the XamComboEditor to white. I tried to get that style a whole day but nothing works.
Can someone help me with this please?
Hi Phillippe,
I have been looking into your question and before I proceed with assisting you I would just like to mention that our forum is divided into dedicated sub-forums for each technology suite. Since the current thread is posted under “Ignite UI for ASP.NET Core” and the question is about our WPF product, regardless of the .NET platform used for the app, please, make sure to post subsequent questions in the dedicated Ultimate UI for WPF sub-forum. Thank you for understanding.
Now to address your questions, since there is a textbox that allows typing, I am assuming the referenced XamComboEditor is the one from the InfragisticsWPF.Controls.Editors.XamComboEditor namespace, isn’t it?
I am asking this, as there is another XamComboEditor, however from the Infragistics.Windows.Editors namespace. Nevertheless, since it does not allow user input, I am assuming you are referring to the former. Please, clarify in case these assumptions are not correct.
So, the text box caret color could be modified by adding a style, targeting SpecializedTextBox element and alreting its CaretBrush property, for example:
<Style TargetType="{x:Type igPrim:SpecializedTextBox}"> <Setter Property="CaretBrush" Value="Red" /> </Style>
xmlns:igPrim=http://schemas.infragistics.com/xaml/primitives
I am attaching a very simple app demonstrating a XamComboEditor along with such a style in its scope. Please, check out this approach and let me know if you require any further assistance on the matter.
Best regards, Bozhidara Pachilova Associate Software Developer
0513.XCEInput-CaretBrush.zip
That's exactly what i was looking for. Thank you very much for your quick help.
I am glad that you find my suggestion helpful. Thank you for using Infragistics components!
Best regards,Bozhidara Pachilova
Can I ask you something more please? Same Control.. but this time I want to make the background of the dropdown toggle button transparent and keep just the small inner triangle. Additionally I want to adjust the font color of the selected combo box item when the dropdown is open.
Thanks in advance.
Sure, regarding your first question, styling the dropdown toggle button would not be as straightforward as it would involve overriding the default styles of the control. Actually, I found this forum thread, where the same question is discussed. You can read all details about the approach in Andrew Goldenbaum’s replies. There are also samples provided that demonstrate the suggestions.
To address your second question, first the element to style you would be interested in is the ComboEditorItemControl. However, there would not be a Selected or similar property on this control, which would allow to target its selected state. Therefore, what needs to be implemented is rather each data item bound to the combo to have a member indicating that the item is selected, which could be used to bind a DataTrigger in the Style, for example:
<ig:XamComboEditor.ItemContainerStyle> <Style TargetType="ig:ComboEditorItemControl" BasedOn="{StaticResource customComboEditorItemControlStyle}"> <Style.Triggers> <DataTrigger Binding="{Binding Path=Item.Data.IsSelected, RelativeSource={RelativeSource Self}}" Value="True"> <Setter Property="Foreground" Value="Green" /> </DataTrigger> </Style.Triggers> </Style> </ig:XamComboEditor.ItemContainerStyle>
More about modifying the selected data items collection via a data model boolean property’s value can be read in the dedicated section in this documentation topic.
For your convenience, I have modified the previous sample to demonstrate this approach. I have also added the necessary styles modifying the toggle button, as suggested in the above referenced forum thread. Please, check it out and of course, do modify the altered styles according to your specific application needs.
If you are unsure, which element you have to modify, for example in the “ComboEditorDictionary.xaml” ResourceDictionary, I can suggest leveraging a tool like Snoop WPF to inspect the target elements.
For instance, some of the modified colors in the sample are for the “selectedRectangle” (line 434), “FocusVisualElement” (line 441) and “mouseOverRectangle” (line 428) in the dictionary.
Best regards,Bozhidara PachilovaAssociate Software Developer
5381.XCEInput-CaretBrushModified.zip
Thank you very much again, you helped me a lot. I've achieved now what i was trying. I wish you a great day!