wpf-styles

WPF: Why would this cause a stack overflow exception?

When I add this style, it breaks my application with a StackOverflowException. <Style TargetType="GroupBox" BasedOn="{StaticResource {x:Type GroupBox}}" > <!-- <Setter Property="Background" Value="{DynamicResource WindowBackgroundBrush}" /> --> </Style> In case it matters, I'm using the ShinyBlue theme. Any ideas what would cause thi...

WPF Updating styles at runtime

I would like to update the default Window style dynamically at runtime so I can change the FontSize and FontFamily dynamically at runtime. I found that Styles in your resource dictionary are sealed at runtime and cannot be changed, so I used the following method of updating the style: <Style TargetType="{x:Type Window}"> <Setter Pro...

WPF - Perform color animation based on previous and current value of a TextBlock

Hi, I have to change the color of a TextBlock to indicate whether the number is positive or negative - red for negative, blue for positive. I have done this by using a DataTrigger and a Converter which returns True/False whether the number is negative/positive. Next requirement is a bit trickier: when the number changes, perform a slow ...

WPF - Color animation on Polygons

Hi, I'm trying to perform a color animation on the fill property of a polygon and getting this error - Cannot convert the value in attribute 'Style' to object of type 'System.Windows.Style'. Cannot resolve all property references in the property path 'Fill.Color'. Verify that applicable objects support the properties. Error at object ...

Split WPF Style XAML Files

Most WPF styles I have seen are split up into one very long Theme.xaml file. I want to split mine up for readability so my Theme.xaml looks like this: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; <ResourceDictionar...

How to parametrize WPF Style?

Hi! I'm looking for a simplest way to remove duplication in my WPF code. Code below is a simple traffic light with 3 lights - Red, Amber, Green. It is bound to a ViewModel that has one enum property State taking one of those 3 values. Code declaring 3 ellipses is very duplicative. Now I want to add animation so that each light fades i...

WPF Binding in Style

Hi, I'm trying to set together a simple textbox with some watermark text in the background. My code is based on the example from Philip Patrick's blog. I'm trying to tweak it so that the text displayed in the background is retrieved from the ToolTip property on the TextBox. Currently this works: <TextBox ToolTip="Type a name here...">...

WPF: Why does ItemsPresenter override my DataGrid's foreground style?

I have a DataGrid style in App.xaml: <Style TargetType="{x:Type DataGrid}"> <Setter Property="Foreground" Value="{StaticResource DataGridItemTextBrush}" /> <Setter Property="VerticalGridLinesBrush" Value="{StaticResource GridBrush}" /> <Setter Property="HorizontalGridLinesBrush" Value="{StaticResource GridBrush}" /> <Set...

creating a design in wpf using stackpanel and reusing it?

I want to create a design using Stackpanel in XAML pad in WPF and then embed images on it using .cx file. But I am getting some error using Styles. <Style x:Key="TopPanelDesign" TargetType="{x:Type StackPanel}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type StackPan...

WPF Window Style not working at runtime

Hi, I created a WPF application in Visual Studio 2010 Express (C#) and added the text below to the Application.Resources in App.xaml. I see the style applied to the window in the designer, but when I run the application, the window background is white. Running in Windows XP on BootCamp on a MacBook Pro if that is a factor. Thanks in...

WPF: Is it possible to add or modify bindings via styles or something similar?

I'm still learning the WPF ropes, so if the following question is trivial or my approach wrong-headed, please do speak up... I'm trying to reduce boilerplate and it sounds like styles are a common way to do so. In particular: I've got a bunch of fairly mundane data-entry fields. The controls for these fields have various properties I...

WPF 4: MergedDictionaries don't seem to work any more

I have the below block of XAML 'BaseStyles.xaml <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="ShinyBlue.xaml"/> <ResourceDictionary Source="DataGr...

Is there a way to display formatted rich text in WPF datagrid?

I'm trying to display rich text inside of a column of a WPF DataGrid (from WPF Toolkit). Something like this: Name: Bob Title: Doctor I am creating a data object programmatically in code with the string property. And I want this string to contain the rich text and than bind it to the column contents. Is that possible? Would really ap...

Inheriting styles in custom WPF controls

I have a datagrid, and certain columns need to contain text that is linked to a detail window. So, in order to make it a bit easier on myself, I created a UserControl that is basically a Button with a control template that contains a TextBlock (I could have done this a number of other ways, I know, but I figured the button already expose...

How to create unselectable TreeViewItem in WPF

I'm binding TreeView. My reason is treeview level 0 is unselectable. When i click level 0 treeviewitem, current item must be collapse and first child item must be selected. ├ Item 1 //<- level 0. this item must be unselectable ├─ Child Item 11 //<- level 1 ├─ Child Item 12 ├ Item 2 //<- level 0. When i click this item, that is auto...

Change Button.Content through style programmatically

I would like to programmatically change content of button via style change. I created a style, added setter for Button.ContentProperty, set new style to button, but content was not changed. I know that I can set button content directly, but now I would like to know why this does not work: Style aStyle = new Style(); Setter bSetter ...

OuterGlowBitmapEffect Alternative Without BitmapEffects

What is a good alternative to OuterGlowBitmapEffect? Preferably one that can be used in a theme/style and one that can be used without BitmapEffects. ...

WPF: ContentPresenter changing Foreground unexpectedly depending on where styles are located

Hi, I'm having an issue with the ContentPresenter behaving unexpectedly based on whether the styles are located in the Window.Resources or in a ResourceDictionary. Specifically, I'm setting the Foreground of the default TextBlock to Black, then setting the Foreground value in my default button style to White. If the styles exits on the...

WPF: How do I get different templates based on a list-item's type?

I heard that I could create a collection of mixed types and have a different Data Template for each type. How woudl I do that for a ListBox? ...

wpf toolkit (Feb 2010) datagrid with MVVM - style reveals name of view model on 'spare column'

Hi, I've just updated my app with the latest WPF toolkit and I've now got an issue with my styling. When I bind some data with, for example, two columns to the grid, the header in the spare area at the right shows the name of the ViewModel. So if I bind an IEnumerable with two columns the Grid Header looks like Column1, Column1, [Nam...