Change selected and unfocused Listbox style to not be grayed out

I have done something like this using the following in a merged ResourceDictionary, it may help you: <Style TargetType=”ListBoxItem”> <Style.Resources> <!–SelectedItem with focus–> <SolidColorBrush x:Key=”{x:Static SystemColors.HighlightBrushKey}” Color=”LightBlue” Opacity=”.4″/> <!–SelectedItem without focus–> <SolidColorBrush x:Key=”{x:Static SystemColors.InactiveSelectionHighlightBrushKey }” Color=”LightBlue” Opacity=”.4″/> </Style.Resources> </Style>

Why is ListBoxFor not selecting items, but ListBox is?

I’ve stumbled across this problem myself, finally I realized that the problem was a naming convention. You cannot name the ViewBag or ViewData poperty containing the SelectList or MultiSelectList to the same name your property model containing the selected items. At least not if you’re using the ListBoxFor or DropDownListFor helper. Here’s an example: public … Read more

How does ItemContainerGenerator.ContainerFromItem work with a grouped list?

You have to listen and react to the ItemsGenerator.StatusChanged Event and wait until the ItemContainers are generated before you can access them with ContainerFromElement. Searching further, I’ve found a thread in the MSDN forum from someone who has the same problem. This seems to be a bug in WPF, when one has a GroupStyle set. … Read more

WPF Listbox auto scroll while dragging

Got it. Used the event DragOver of the ListBox, used the function found here to get the scrollviewer of the listbox and after that its just a bit of juggling with the Position. private void ItemsList_DragOver(object sender, System.Windows.DragEventArgs e) { ListBox li = sender as ListBox; ScrollViewer sv = FindVisualChild<ScrollViewer>(ItemsList); double tolerance = 10; double … Read more

Listview inside of scrollviewer prevents scrollviewer scroll

That happens because the ListView‘s (ListBox‘s, actually) content template wraps its items with a ScrollViewer by itself. The simplest way is to disable it by dropping your own Template for the inside ListView, one that doesn’t create a ScrollViewer: <ListView> <ListView.Template> <ControlTemplate> <ItemsPresenter></ItemsPresenter> </ControlTemplate> </ListView.Template> … </ListView> BTW the same happens if you have a … Read more

disable mouse wheel on itemscontrol in wpf

This can be accomplished via attached behaviors. So instead I came up with the following IgnoreMouseWheelBehavior. Technically it’s not ignoring the MouseWheel, but it is “forwarding” the event back up and out of the ListBox. Check it. /// <summary> /// Captures and eats MouseWheel events so that a nested ListBox does not /// prevent an … Read more

WPF ListBox with a ListBox – UI Virtualization and Scrolling

It is possible to achieve smooth scrolling VirtualizingStackPanels in WPF 4.0 without sacrificing virtualization if you’re prepared to use reflection to access private functionality of the VirtualizingStackPanel. All you have to do is set the private IsPixelBased property of the VirtualizingStackPanel to true. Note that in .Net 4.5 there’s no need for this hack as … Read more

WPF Drag & drop from ListBox with SelectionMode Multiple

I’ve found a very simple way to enable Windows Explorer like drag/drop behaviour when having multiple items selected. The solution replaces the common ListBox with a little derived shim that replaces the ListBoxItem with a more intelligent version. This way, we can encapsulate the click state at the right level and call into the protected … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)