I wish to allow the user to select from any of the Infragistics Themes for the application. It seems that for the MetroDark theme the Foreground property of the TextBlock is set to black and thus doesn't show up on the (almost) black background.
I can workaround this by binding the TextBlock Foreground to the Foreground property of a Label control (as in the attached example), but that rather defeats the concept of using themes.
Is this a bug, or am I missing something?
Hello peterhutchinson,
Thank you for your post.
I have been testing against the sample project that you have provided, and it appears that there is a missing implicit style for TextBlock in our MetroDark theme files that would normally set the Foreground of the TextBlock in your sample. This is unexpected, and I have asked our engineering teams to investigate further. To ensure that it receives attention, I have logged this issue in our internal tracking system with a development ID of 221126.
I have also created a support case on your behalf, which I will link this development issue to so that you can track its progress. This case has an ID of CAS-174436-X0C2Y2 and you can access it at https://ko.infragistics.com/my-account/support-activity.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer
I have received an update from our development teams on this matter. The implicit style for TextBlock was intentionally left out of the MetroDark theme. The reason for this is because adding an implicit style that effects every TextBlock it touches can sometimes be rather dangerous. Sometimes it will affect a TextBlock that we don't necessarily have access to, and if you don't want this style applied to that TextBlock for some reason, it can cause the need for changes that aren't so easily fixed.
For example, take a ListBox control in WPF. Inside each ListBoxItem that exists in this ListBox, there exists a ContentControl, which contains a ContentPresenter, which contains a TextBlock, which we cannot directly style. On MouseOver or selection of the ListBoxItem, the TextBlock content highlights since it is the real content of the ListBoxItem, and that is done by changing the Foreground color of the ContentControl that contains the TextBlock. Now, if we were to add an implicit style for TextBlock, then these stylings would no longer be applied, and you would end up with a result much like the attached picture. If you wanted to apply this styling to the TextBlock where the TextBlock highlights on selection, you would need to find a workaround to do so.
I would recommend that you continue to set the TextBlock's Foreground property in this case.
Thanks for the explanation, Andrew. I see the problem!
Perhaps there's a need for an xamTextBlock control which does restyle itself according to the selected theme? Meanwhile... it's back to setting the Foreground property as you suggest.
Thanks again
Peter
Hello Peter,
Thank you for your response.
The closest thing that I believe we have in our WPF toolset to a "xamTextBlock" would likely be our editor or input controls, but these are more used for editing values than just displaying them. If you want a control that isn't editable, displays text, and takes the MetroDark style implicitly without having to set the Foreground property, why not just use a Label control, as we have confirmed that this works with the MetroDark theme.
Alternatively, if you would like to possibly see a TextBlock derivation implemented in a future version of Infragistics for WPF, you can suggest a new product idea for it at http://ideas.infragistics.com. This site will place you in direct communication with our product management team who plan and prioritize upcoming features and products based on community and user feedback.
Hi Andrew, thanks for the further suggestion. After further research, I find that the only practical difference between a Label and a TextBlock (apart from TextBlock being a more lightweight control) seems to be that TextBlock has the TextWrapping property. However, if I need that functionality, I can place a TextBlock within the Label control as its Content. Changing the theme then appropriately changes the foreground property of that TextBlock (by analogy with your ListBox example above).
Problem solved!
Thank you for your update. It is good to see that you have found a solution to workaround these issues that you were having with the MetroDark theme.