How to display a different value for dropdown list values/selected item in a WPF ComboBox?

Update 2011-11-14 I recently came upon the same requirement again and I wasn’t very happy with the solution I posted below. Here is a nicer way to get the same behavior without re-templating the ComboBoxItem. It uses a DataTemplateSelector First, specify the regular DataTemplate, the dropdown DataTemplate and the ComboBoxItemTemplateSelector in the resources for the … Read more

How to create/make rounded corner buttons in WPF?

I know this post is super old, but I have an answer that’s surprisingly missing from the above and is also much simpler than most. <Button> <Button.Resources> <Style TargetType=”Border”> <Setter Property=”CornerRadius” Value=”5″/> </Style> </Button.Resources> </Button> Since the default ControlTemplate for the Button control uses a Border element, adding a style for Border to the Button’s … Read more

Formatting text in a TextBlock

You need to use Inlines: <TextBlock.Inlines> <Run FontWeight=”Bold” FontSize=”14″ Text=”This is WPF TextBlock Example. ” /> <Run FontStyle=”Italic” Foreground=”Red” Text=”This is red text. ” /> </TextBlock.Inlines> With binding: <TextBlock.Inlines> <Run FontWeight=”Bold” FontSize=”14″ Text=”{Binding BoldText}” /> <Run FontStyle=”Italic” Foreground=”Red” Text=”{Binding ItalicText}” /> </TextBlock.Inlines> You can also bind the other properties: <TextBlock.Inlines> <Run FontWeight=”{Binding Weight}” FontSize=”{Binding Size}” … Read more