datatrigger

WPF Calling method from a DataTrigger

天涯浪子 提交于 2019-12-06 01:31:17
问题 Is it possible to use a wild card or call a method to work out if a DataTrigger should be applied? I currently have my DataList bound to an IEnumerable that contains file names and I want the file names to be greyed out if there files extension starts with "old" My non-working dream xaml markup looks something like this: <DataTemplate.Triggers> <DataTrigger Binding="{Binding}" Value="*.old*"> <Setter TargetName="FileName" Property="Foreground" Value="Gray"/> </DataTrigger> </DataTemplate

WPF Toolkit DataGridCell Style DataTrigger

大兔子大兔子 提交于 2019-12-05 18:46:52
I am trying to change the color of a cell to Yellow if the value has been updated in the DataGrid. My XAML: <toolkit:DataGrid x:Name="TheGrid" ItemsSource="{Binding}" IsReadOnly="False" CanUserAddRows="False" CanUserResizeRows="False" AutoGenerateColumns="False" CanUserSortColumns="False" SelectionUnit="CellOrRowHeader" EnableColumnVirtualization="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"> <toolkit:DataGrid.CellStyle> <Style TargetType="{x:Type toolkit:DataGridCell}"> <Style.Triggers> <DataTrigger Binding="{Binding IsDirty}" Value="True"> <Setter Property=

WPF ComboBox Doesn't Display SelectedItem after one DataTrigger but does for another

你离开我真会死。 提交于 2019-12-05 11:17:14
So I have a combobox I'd like to reuse for multiple sets of data rather than having 3 separate comboboxes. Maybe this is bad and someone can tell me so. I'm open to all ideas and suggestions. I'm just trying to clean up some code and thought one combobox rather than 3 was cleaner. Anyway the ItemsSource and SelectedItem all should change when another ComboBox's value is changed which Raises the Property Changed value for the ComboBox that isn't working. The worst part is when CurSetpoint.ActLowerModeIsTimerCondition is true it always loads the SelectedItem correctly but when going from that to

TemplateBinding from a Style DataTrigger In ControlTemplate

删除回忆录丶 提交于 2019-12-05 07:22:24
In the following XAML I'm using a Rectangle with a Border as the Template for a ToggleButton. I want the BorderBrush to be a different colour to reflect the changing value of ToggleButton.IsChecked. Unfortunately my attempt here of using a TemplateBinding in the DataTrigger doesn't work. What do I need to do instead? <StackPanel Orientation="Horizontal"> <StackPanel.Resources> <ControlTemplate x:Key="ButtonAsSwatchTemplate"> <Border BorderThickness="1"> <Border.Style> <Style> <Setter Property="BorderBrush" Value="Gainsboro" /> <Style.Triggers> <!-- TemplateBinding doesn't work.--> <DataTrigger

WPF TextBlock Negative Number In Red

扶醉桌前 提交于 2019-12-05 03:22:36
I am trying to figure out the best way to create a style/trigger to set foreground to Red, when value is < 0. what is the best way to do this? I'm assuming DataTrigger, but how can I check for negative value, do i have to create my own IValueConverter? Wonko the Sane If you are not using an MVVM model (where you may have a ForegroundColor property), then the easiest thing to do is to create a new IValueConverter, binding your background to your value. In MyWindow.xaml: <Window ... xmlns:local="clr-namespace:MyLocalNamespace"> <Window.Resources> <local:ValueToForegroundColorConverter x:Key=

Remove storyboard but keep animated value?

六眼飞鱼酱① 提交于 2019-12-05 01:39:23
How can I remove a storyboard in XAML (i.e. RemoveStoryboard action in a DataTrigger) but keep the value that was animated. Similar to the Animatable.BeginAnimation : If the animation's BeginTime is null, any current animations will be removed and the current value of the property will be held. RemoveStoryboard's primary use is to remove the animated values and set them back to their un-animated state. In most cases you can just switch the call to PauseStoryboard or StopStoryboard instead, depending on the specific case. The only exception is when you need to free up resources held by the

WPF Datatrigger Visibility + Null Value

瘦欲@ 提交于 2019-12-05 01:05:50
问题 I'm beginner in WPF. I want to set Visibility to Hidden on a Radiobutton when the databind value is equal to Null. I'm using WPF Toolkit. This is my code but it doesn't work : <dg:DataGrid x:Name="dtGrdData" HorizontalScrollBarVisibility="Hidden" SelectionMode="Extended" CanUserAddRows="False" CanUserDeleteRows="False" CanUserResizeRows="False" CanUserSortColumns="False" AutoGenerateColumns="False" RowHeaderWidth="0" RowHeight="50" > <DataTrigger Binding="{Binding P_DAY_PRICE}" Value="{x:Null

Making a WPF Label (or other element) flash using animation

一世执手 提交于 2019-12-05 00:58:09
I have a label that I only make visible based on one of my ViewModel Properties. Here is the XAML: <Label HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="24" Width="200" Height="200" > <Label.Content > Option in the money! </Label.Content> <Label.Style> <Style TargetType="{x:Type Label}"> <Setter Property="Visibility" Value="Hidden" /> <Style.Triggers> <DataTrigger Binding="{Binding OptionInMoney}" Value="True"> <Setter Property="Visibility" Value="Visible" /> </DataTrigger> </Style.Triggers> </Style> <

How to set the default value of DateTime to empty string?

会有一股神秘感。 提交于 2019-12-04 16:49:49
I have a property called Raised_Time, this property shows the time at which alarm is raised in datagrid Cell. I don't want to show anything in the datagrid cell when user creates any alarm, it just display the empty cell. I googled in the internet and found that the default value of DateTime can be set using DateTime.MinValue and this will display MinValue of datetime i:e "1/1/0001 12:00:00 AM". Instead I want that the datagrid cell remain blank until alarm is raised, it don't show any time. I think datatrigger can be written in this case. I am not able to write the datatrigger for this

Can you bind a DataTrigger to an Attached Property?

淺唱寂寞╮ 提交于 2019-12-04 15:53:43
问题 In WPF, is it possible for a DataTrigger to bind to an attached property? I essentially want to use a converter on an attached property to provide a style when a particular validation rule has been broken. I am using markup like the following: <DataTrigger Binding="{Binding Path=Validation.Errors, RelativeSource={RelativeSource Self}, Converter={StaticResource RequiredToBoolConverter}}" Value="True"> <Setter Property="Background" Value="LightGreen" /> </DataTrigger> However, when this runs, I