ComboBox with rounded corner - wpf

I am new to wpf and I wanted to change the ComboBox style to this However all I could do was to change the highlight color.
<ComboBox.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.WindowBrushKey}" Color="#FF374046" />
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#FF374046" />
</ComboBox.Resources>
If anyone could guide me to understanding how to create it I would be thankful.

Have a quick glance at http://www.wpfhelper.com/index.php/styles-in-wpf/combobox/15-combobox-style-in-wpf. As mentioned in the comments, you need to create your own custom style & template for the ComboBox, ComboBoxItem and ComboBox ToggleButton. Play around with the CornerRadius of the popup element, to start with.

Related

WPF DataGridRow custom style is dismissed when the Datagrid looses focus

In a scenario of a WPF form with multiple data grids, I have been (unsuccessfully) trying to conditionally change specific rows (background) color, which effect would signify to the user a optically detectable circumstance.
During trials although I have been able to set the (background) color correctly either by the use of Data triggers and bindings or by handling the LoadingRow event, the row style is getting dismissed when the grid controls lose focus.
As some people suggested the only way to by-pass this is by using the System.HighlightBrush which indeed works : despite the lost of focus, the rows of interest retain their style.
If I follow the aforementioned technique, is there a way to change the color of the HighlightBrush to something other than the standard system default light blue one?
Define your own brushes for HighlightBrushKey and InactiveSelectionHighlightBrushKey and put them in the Resources dictionary of the DataGrid:
<DataGrid ...>
<DataGrid.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="Transparent"/>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black"/>
</DataGrid.Resources>
</DataGrid>

WPF ListBox: Vertical scrollbar and focus

I have two problems regarding a ListBox/WrapPanel.
First of all, my setup:
In XAML I have a ListBox. Inside of the ListBox is a WrapPanel. Programatically I add ListBoxItems to the WrapPanel.
Problem one
The ListBoxItems [StackPanel with Image and TextBlock] fills left to right and up to down. However, a vertical scrollbar does not appear if there are more ListBoxItems than there is space in the ListBox. The following XAML code makes the vertical scrollbar visible. However, it remains disabled:
<ListBox Name="li1StandortLinks" Background="Transparent" MaxHeight="300" ScrollViewer.VerticalScrollBarVisibility="Visible">
<WrapPanel Name="wp1StandortLinks" ItemHeight="80" ItemWidth="150" Width="755" />
</ListBox>
How to get a functional vertical scrollbar when needed?
Problem two
When clicking into the ListBox but not at a ListBoxItem [for example, in between two of them], the background of the whole ListBox gets highlighted in blue. Initially the background is transparent and it should remain like this even if the ListBox itself was clicked. Catching the Click-Event and setting the background back to transparent seems not to help. The blue highlight-color does disappear, but instead of the ListBox background going back to transparent, it then remains grey.
Can I change the style so that the color does not change at all when clicking at the ListBox? I never really changed styles in WPF, though, so I'd need a precise explaination.
this may work for problem one :
<ListBox Name="li1StandortLinks" Background="Transparent" MaxHeight="300" ScrollViewer.VerticalScrollBarVisibility="Visible">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
for problem 2 :
this may work too (change style for your listbox)
<ListBox Name="li1StandortLinks" Background="Transparent" MaxHeight="300" ScrollViewer.VerticalScrollBarVisibility="Visible">
<ListBox.Style>
<Style TargetType="ListBox">
<Style.Resources>
<!-- Background of selected item when focussed -->
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
<!-- Background of selected item when not focussed -->
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" />
</Style.Resources>
</Style>
</ListBox.Style>
</ListBox>

WPF : Making a nice menu - how to make an animation on some focus?

I'm quite new to the "nice" WPF application and until now I was very focused on the architecture part(MVVM and stuff). I'm looking to improve this and I'm trying some things.
Currently I'm trying to do this kind of menu:
Every element on the left would be triggering some action to navigate on the part on the right.
What I'm currently failing to achieve is the green part, because I would like that now, if I click on "Settings", the green element "move" to settings(in fact, move to the bound SelectedItem.
I'm not sure what is my best option to achieve this?
Use a ListBox control. Style the ListBoxItem to set a particular colour for the HighlightBrushKey:
<ListBox>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Green" />
</Style.Resources>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>

TreeView shows blue for selected item

I have a treeview structure. When I try to click on the nodes there is a blue color that shows the node selected. How can I remove that.
I don't want a selection color to be displayed on the tree.
ItemContainerStyle method does not work for me say on Windows-8. There are 4 brushes that generally correspond to this and are used by the default Template for TreeViewItem
keys:
HighlightBrushKey - Background with focus.
HighlightTextBrushKey - Foreground with focus.
InactiveSelectionHighlightBrushKey - Background without focus.
InactiveSelectionHighlightTextBrushKey - Foreground without focus.
Just override them as you see fit, for your requirement something like this would do fine:
<TreeView>
<TreeView.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
Color="Transparent" />
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}"
Color="Black" />
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}"
Color="Transparent" />
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}"
Color="Black" />
</TreeView.Resources>
</TreeView>
Do pay attention to only overriding them within the scope you require. For example if you put all this into App.xaml you're going to see some weird side-effects as all control's using these Brushes would now end up using your overridden ones which may not be what you're after.

Changing the arrow color in WPF Toolkit NumericUpDown control?

Is there a way with a style to target the arrows in the NumericUpDown control from the WPF Toolkit? I want to change the color of the arrows.
You can override the GlyphNormalForeground color.
you will have to add the Xceed.Wpf.Toolkit.Themes xmnls namespace to your xaml.
(or WpfToolkit.Themes if your using the old version)
Example:
<Grid>
<wpfToolkit:IntegerUpDown Margin="37,25,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" >
<wpfToolkit:IntegerUpDown.Style>
<Style TargetType="{x:Type wpfToolkit:IntegerUpDown}">
<Style.Resources>
<SolidColorBrush x:Key="{x:Static theme:ResourceKeys.GlyphNormalForegroundKey}" Color="Red"/>
</Style.Resources>
</Style>
</wpfToolkit:IntegerUpDown.Style>
</wpfToolkit:IntegerUpDown>
</Grid>
Result:
To add Xceed.Wpf.Toolkit.Themes namespace use this
xmlns:theme="clr-namespace:Xceed.Wpf.Toolkit.Themes;assembly=Xceed.Wpf.Toolkit"

Resources