Tag Archives: WPF

WPF how to stretch listbox content item

Something I’ve been search for, for quit some times is how to stretch the content of a listbox in WPF. If you add a textbox to a listbox item, the textbox will only take as much space as it needs (to make it more visible I’ve add a border and a backgroundbrush): Of course I’ve […]

Comments Off on WPF how to stretch listbox content item  

Use XAML resource in WPF IValueConverter

If you don’t want to hardcoded┬ástyles and colors in you WPF, Silverlight or WP7 project you’ve probably added some styles and predefined colors in the APP.XAML file: <Style TargetType="TextBlock" x:Key="Style1"> <Setter Property="Foreground" Value="Black"/> <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeLarge}"/> <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiLight}"/> </Style> <Style TargetType="TextBlock" x:Key="Style2"> <Setter Property="Foreground" Value="Red"/> <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMedium}"/> <Setter Property="FontFamily" Value="{StaticResource […]

Comments Off on Use XAML resource in WPF IValueConverter  

Get brush from hex color in WPF, Silverlight, Windows Phone

For an app I created I needed to create a solidcolorbrush from hex RGB string. Seems a simple task, but there is no simple way of doing this. But I’ve created simple method that does just this: public static SolidColorBrush GetBrushFromHexString(string aarrggbb) { string xamlString = "<Canvas xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" Background=\"" + aarrggbb + "\"/>"; Canvas c […]

Comments Off on Get brush from hex color in WPF, Silverlight, Windows Phone