wpf-triggers

What is the difference between triggers and events in WPF?

What are main difference between Triggers and Events in WPF ? We can do all the stuffs using events, which we can do through triggers, so why we need triggers? ...

Why won't this load storyboard event in WPF not fire?

Ok for some reason I've set up an event trigger for window.loaded in WPF to fire the AnimationBoard storyboard but for some reason it doesn't want to load. Any ideas out there? Thanks! Below is the code: <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ...

Giving a WPF ItemsControl a different look based off whether ItemsSource holds a single value or multiple values?

Are there any slick ways to style/template a WPF ItemsControl differently based off whether ItemsSource holds a single value or multiple values? What I've done so far is to create a custom ItemsControl class which among other things displays the list of bound items as a horizontally oriented comma separated list. So far I'm pretty happy...

WPF Listview modification

For a very specific reason I want to select ListViewItems on mouse button up, not actually on mouse button down. I want this behaviour to be embedded in the control. Is it possible to achieve this? can anyone give hint? ...

WPF: How do I set the Foreground property of a TextBlock using DataTrigger

This is my XAML: <TextBlock Name="SeverityText" Grid.Column="1" Grid.Row="0" Foreground="Red"> <TextBlock.Triggers> <DataTrigger Binding="{Binding Path=Severity}"> <DataTrigger.Value> <sm:Severity>Warning</sm:Severity> </DataTrigger.Value> ...

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 ...

How to set MouseOver event/trigger for border in XAML?

How to set MouseOver event/trigger for border in XAML? I want the border to turn green when the mouse is over it and then to return to blue when the mouse is no longer over the border. Why can't I just use the following code: <Border Name="ClearButtonBorder" Grid.Column="1" CornerRadius="0,3,3,0" Background="Blue"> ...

How to display combo box as textbox in WPF via a style template trigger?

I would like to display a combobox drop down list as a textbox when it's set to be read only. For some reason I can't seem to bind the text of the selected item in the combo box to the textbox. This is my XAML: <Style x:Key="EditableDropDown" TargetType="ComboBox"> <Style.Triggers> <Trigger Property="IsReadOnly" Val...

Combobox in WPF loses its theme when using a style trigger. (Stumper?)

I am using style triggers to change combo box to texbox if it's readonly, but for some reason when I apply the style, it cause the combobox theme to change from Aero to Windows Classic (the theme I currently have in use on my PC). Any help would be GREATLY appreciated! Here is my code: <ComboBox ItemsSource="{Binding Source={StaticRe...

Why Trigger is null in the code behind (Silverlight)?

I have created a trigger in the xaml and it works fine. However, when I want to access one of its properties in the code behind it always gives me a null value. Anyone knows why? ...

What is the behavior of a WPF 4 ControlStoryboardAction trigger?

Hi all! I have a question that's been bugging me for a while: I have a lengthy IO operation which I invoke asynchronously, and I want my UI to show a blinking text to tell the users that the data is loading. I have an IsLoading boolean property in my ViewModel, and I used a ControlStoryboardAction to kickoff the blinking animation, wh...

WPF - Setting usercontrol width using triggers and mouseenter event

I have a wrap panel full of usercontrols. When I hover the mouse over a usercontrol I want it to expand to show more details. Some stripped down sample code: <UserControl x:Class="WPFTestBed.UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ...

Wpf: Storyboard.TargetName works, but Setter TargetName doesn't.

Hi, Let's say we have a XAML code like this: <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ListBoxItem}"> <Border HorizontalAlignment="Center" VerticalAlignment="Center"> <Border.LayoutTransform> ...

Can I use Property Trigger to get selected items from WPFToolkit datagrid ?

Hi, I have a wpfToolkit-datagrid. Can I use a trigger for the following "IsSelected" property to update a selectedItems list in view-model ? < Style TargetType="tk:DataGridRow"> < Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" /> < /Style> ...

Show animation when databound property changess to *any* value

Is there a way to attach a trigger (and a subsequent animation) to a control which has a property databound, and have that trigger fire when the value of that databound property changes (to ANY value). I don't care what value it is, I just want to show a notification when the value changes to something else. Might be very obvious, but I...

Question regarding WPF triggers

Hi, I have a problem with WPF triggers. In my application i used a multitrigger but would like to achieve that changes made when a trigger's conditions become true to persist and NOT to be invalidated when the trigger's conditions become false AGAIN. Is it possible to realize what I want ? Thanks in advance. ...

Setter in property trigger fails if target property already has an explicit value

I'm currently trying to create a ControlTemplate for the Button class in WPF, replacing the usual visual tree with something that makes the button look similar to the little (X) close icon on Google Chrome's tabs. I decided to use a Path object in XAML to achieve the effect. Using a property trigger, the control responds to a change in t...

How to dynamically collapse a WPF element such as Border when it has no child element?

I have found the need to collapse a given WPF element or control when it is visually empty and I'm curious whether others have come across this and if so what type of solutions have worked. My current case is one where I have a Border control that either will have a child element or not depending on various cases. When Border.Child is n...

where to put StateChanged triggers?

Hi, Where do we put the StateChanged trigger from expressionblend.codeplex.com ? <i:Interaction.Triggers> <sam:StateChanged Completed="True" StateName="BeforeUnloaded"> <... /> </sam:StateChanged> </i:Interaction.Triggers> the above code i tried gave me a compile error saying A value of type 'StateChanged' cannot be added to...

TextDecorations not being applied to TextBlock during a TreeViewItem Style Trigger

Hi, I have a WPF application in which I would like to decorate logically deleted items (held in a TreeView) by displaying them with the Strikethrough TextDecoration. I can get the style trigger to successfully apply a Foreground color when fired, but when I try to set the TextDecorations it has no effect. Here is some sample code that...