WPF ListView ScrollBar visible to false

You can specify the visibility of the scrollbar for both vertical and horizontal scrolling to four options, using the ScrollViewer.HorizontalScrollBarVisibility and ScrollViewer.VerticalScrollBarVisibility attached properties: Auto, Disabled, Hidden and Visible. <ListView ScrollViewer.HorizontalScrollBarVisibility=”Disabled”> Disabled will have it never show up and scrolling is not possible, Hidden will have it not show, but will allow users to scroll … Read more

How to capture a mouse click on an Item in a ListBox in WPF?

I believe that your MouseLeftButtonDown handler is not called because the ListBox uses this event internally to fire its SelectionChanged event (with the thought being that in the vast majority of cases, SelectionChanged is all you need). That said, you have a couple of options. First, you could subscribe to the PreviewLeftButtonDown event instead. Most … Read more

WPF DataGrid: CommandBinding to a double click instead of using Events

No need for attached behaviors or custom DataGrid subclasses here. In your DataGrid, bind ItemsSource to an ICollectionView. The trick here is to set IsSynchronizedWithCurrentItem=”True” which means the selected row will be the current item. The second part of the trick is to bind CommandParameter to the current item with the forward slash syntax. When … Read more

Whats the difference between ContentControl.Template and ContentControl.ContentTemplate

Template property defines the appearence of a Control itself and ContentTemplate defines the template of the Content area of a Control. Interesting point from MSDN: If a Control does not have a ControlTemplate, the Control will not appear in your application. This becomes more clear when we take a look at the data types of … Read more

“Are you sure?” prompts. Part of the ViewModel or purely the view?

The prompts should definitely not be part of the ViewModel, but this doesn’t necessarily mean that the best solution is to hardcode them in the View (even though that’s a very reasonable first approach). There are two alternatives that I know of which can reduce coupling between View and ViewModel: using an interaction service, and … Read more

WPF Change Background color of a Combobox

Try this <Window.Resources> //Put this resourse n Window.Resources or UserControl.Resources <LinearGradientBrush x:Key=”NormalBrush” StartPoint=”0,0″ EndPoint=”0,1″> <GradientBrush.GradientStops> <GradientStopCollection> <GradientStop Color=”#FFDC3939″ Offset=”0.0″/> <GradientStop Color=”#FFE80E0E” Offset=”1.0″/> </GradientStopCollection> </GradientBrush.GradientStops> </LinearGradientBrush> <SolidColorBrush x:Key=”WindowBackgroundBrush” Color=”#FFFBE618″ /> <ControlTemplate x:Key=”ComboBoxToggleButton” TargetType=”ToggleButton”> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition Width=”20″ /> </Grid.ColumnDefinitions> <Border x:Name=”Border” Grid.ColumnSpan=”2″ CornerRadius=”2″ Background=”{StaticResource NormalBrush}” BorderThickness=”1″ /> <Border Grid.Column=”0″ CornerRadius=”2,0,0,2″ Margin=”1″ Background=”{StaticResource WindowBackgroundBrush}” BorderThickness=”0,0,1,0″ … Read more