XAML Listbox background formatting Silverlight - c#

OK so i am passing an Observable collection to the itemsource of a listbox the collection has a color property, and i had been doing the background color within the grid inside the listbox by binding the color. However I need to have the item change color when the mousover event occurs, which doesn't show because the background drawn to the grid overlays the color change on the listboxItem. When I try and bind the color to the listboxitem however it throws an exception.
I could really use some help here I've tried everything i can think of and find.

I found the solution, it turns out this is one of the limitations in Silverlight that is known to the silverlight team, a blog post at http://blogs.msdn.com/b/delay/archive/2009/11/02/as-the-platform-evolves-so-do-the-workarounds-better-settervaluebindinghelper-makes-silverlight-setters-better-er.aspx demonstrates a method to force a binding on a control.

you can write the mouseenter and mouseleave events ,in the mouseenter, you remove the grid backagegroud color and add the item's backagegourd's color. in the mouseleave you remove the item's backagegroud's color and add the grid's backagegroud's color

Related

ListView disabled background color

Hi I draw my items in a ListView by myself (OwnerDraw = true). I don't use DrawDefault = true as I want to have consistent appearance in all styles (Windows Classic, Aero, etc). Now I have the problem that I have to draw the background even if the ListView is disabled. And I can't find the right color for that. The disabled background color of the item should fit the background color of the ListView dependent of the user selected style in Windows. Any ideas how to get this color? Thanks in advance.
I was looking for it, too. It is static member of ListView class: ListView.DefaultBackColor.

C#, wpf and datagrid, set selectedIndex and the row is grey

I have a wpf application that use the MVVM pattern. In code, I set the selectedItem property, that binds the dataGrid property in the axml, and the row has a grey color, instead of blue.
If I select the row with the mouse, then the row is blue.
Why?
I use the binding mode "twoway" for the selectedIndex property.
Thanks.
The gray highlight is probably because it is showing the selected item, but the control itself (the DataGrid) doesn't have focus. The same thing occurs with ListBoxes. Try putting a TextBox on your window next to the DataGrid. Select the row with the mouse and it'll turn blue. Then click in the TextBox and the selection will turn gray.

autocompletebox without highlighted border

I have an autocompletebox that I am trying to remove the border from. Just setting the border to a transparent color or a border thickness of zero isn't good enough, because when the box is moused over, a secondary border appears. The style template for the control is cryptic enough for me that my guesses on changing different parameters have not resulted in border changes.
What do I need to do to disable the border for this control?
Normally, this is due to the FocusVisualElement component in styletemplates for controls.
I can see that the Autocompletebox doesn't have this component, but the Autocompletebox itself is built with more basic controls who do have such an element in their style template.
Try making a style for a textbox without the focusvisualelement (remove it completely from the template) and let the textbox inside the Autocompletebox make use of that template, that should remove the border from the autocompletebox.
So the style contained a control template with the textbox used in the autocomplete user control... I just replaced the style specifically for that textbox to show a transparent border on the mouseover state.

ComboBox DropDownStyle DropDownList : Change BackColor WinForms

I am making one app where I highlight currently focused controls.
For TextBox I use the BackColor property.
But in case of a ComboBox with DropDownStyle = DropDownList, BackColor does not seem to make it highlight.
Any suggestion(border etc?) on how can I make the controls Highlight in a consistent manner.
As Reniuz said, you'll need to change the DrawMode properties.
Specifically, changing the DrawMode to OwnerDrawFixed will allow you to specify the BackColor.
System.DrawMode
Normal - All the elements in a control are drawn by the operating system and are of the same size.
OwnerDrawFixed - All the elements in the control are drawn manually and are of the same size.
OwnerDrawVariable - All the elements in the control are drawn manually and can differ in size.
See System.Windows.Forms.DrawMode for more information.
Try to change FlatStyle or DrawMode properties. But control will look a bit different. May be it will fit for you :)

Transparent LinkLabel over TabControl

I would like to put a LinkLabel with a transparent background over a TabControl. The tab control has NO tabpage.
As it's not possible to add controls other than TabPages to a TabControl, what I do it add the LinkLabel to the control that contains the TabCOntrol, and then use BringToFront on the LinkLabel. This displays it over the TabControl.
Problem: The LinkLabel displays as transparent (BackColor Property), but instead of showing the TabControl's colour as background, it shows the background colour of it's parent, the control that also contains the TabControl.
From what I understand, this is normal behaviour as a Transparent BackColor means that it'll just take the parent's colour.
Question: Is there any solution to display my LinkLabel with the TabControl's background colour?
Thanks
I may be wrong about this, but I think that if you change the LinkLabel's BackColor property in code (e.g. in your form's Load event, as opposed to just setting it in the designer) to match the color of your TabControl, it will work the way you want it to.
Thanks for your answers. I'm now get what you meant.
Using the tab Control's BackColor won't work, because this property always returns the ColorSystemColors.Control, which is greyish. However, when using visual styles (e.g. XP's default theme), the TabControl's back colour is kind of white. I cannot use white either as the tab control is not pure white, but gradient white...

Categories