datatrigger

WPF Animation Only Firing Once

久未见 提交于 2019-12-23 15:55:31
问题 I have a small ellipse that I want to flash every time a dependency property gets set to true. Because the property can very quickly go from true back to false in a matter of milliseconds, I need to do this with an animation and not a simple style datatrigger. Basically, I just want the true value to ping an animation on the ellipse. <Ellipse Height="10" Width="10" Stroke="#FFFFFFFF" Margin="5,3,0,0"> <Ellipse.Fill> <SolidColorBrush /> </Ellipse.Fill> <Ellipse.Style> <Style> <Style.Triggers>

How do I bind a datatrigger in xaml to a code-defined dependency property?

眉间皱痕 提交于 2019-12-23 13:08:15
问题 My code behind for a window defines a dependency property, "Active"... public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } public bool Active { get { return (bool) GetValue(ActiveProperty); } set { SetValue(ActiveProperty, value); } } public static readonly DependencyProperty ActiveProperty = DependencyProperty.Register("Active", typeof(bool), typeof(MainWindow), new UIPropertyMetadata(false)); } And then I bind to that property using two checkboxes in

TextBox's Text set through DataTrigger not updating the property value in Model

流过昼夜 提交于 2019-12-23 12:25:11
问题 I am new to WPF and I want to clear a textBox's value if a check box is unchecked. I tried doing that through data triggers. Below is the code: <TextBox Text="{Binding Path=Amount,Mode=TwoWay}"> <TextBox.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding Path=IsSelected}" Value="false"> <Setter Property="TextBox.Text" Value="{x:Null}"></Setter> </DataTrigger> </Style.Triggers> </Style> </TextBox.Style> </TextBox> My checkbox's value is set in "IsSelected" property of My Model.

How to create converter to work like “FindAncestor” for checking IsTypeFound?

随声附和 提交于 2019-12-23 05:34:06
问题 I want to create a converter in which I will pass a type to find, in element's parent hierarchy & it should return true if such a type found, otherwise false. So far, I tried below given code & it is working. but now only i have issue is it finds element parent hierarchy until element's parent is null. I want to give ancestor level for finding element in parent hierarchy. So How can I give Ancestor Level to converter?? I used LayoutHelper.cs Class to find element in parent hierarchy as given

How to write DataTrigger to Visible the Filter Icon in the DataGrid While on Mouse Hover or Popup IsOpen?

拈花ヽ惹草 提交于 2019-12-23 04:46:10
问题 How to Set Filter Icon in the DataGrid, it should be Visible on MouseOver and Filter Popup IsOpen otherwise Collapsed. Note: Design the Datagrid in one XAML and the Filter Popup should be in Main View XAML, The DataGrid XAML inherits the Main View XAML. The Filter Icon is a Button designed in app.xaml and call the Style in the DataGrid. I need to show ( Visibility:Visible ) the Filter Icon Button while on Mouse Hover Event of the Corresponding Column or If user can click the Filter Icon

Usage DataTrigger in WPF

落花浮王杯 提交于 2019-12-23 03:13:38
问题 I have a TextBox control defined in XAML and I want to apply different background colors to the TextBox based on its IsReadOnly or IsEnabled properties. I used dataTriggers to actually switch between the colors as shown below: <Style x:Key="TextBoxStyle" TargetType="TextBox"> <Style.Triggers> <DataTrigger Binding="{Binding IsEnabled}" Value="True"> <Setter Property="TextBox.Background" Value="Yellow"/> </DataTrigger> <DataTrigger Binding="{Binding IsReadOnly}" Value="True"> <Setter Property=

WPF Toolkit DataGridCell Style DataTrigger

别等时光非礼了梦想. 提交于 2019-12-22 10:59:29
问题 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

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

荒凉一梦 提交于 2019-12-21 22:24:57
问题 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.

How to make a text box Visibility=Hidden with a trigger

风流意气都作罢 提交于 2019-12-20 10:38:04
问题 I seem to be having a hard time today. All I want to do is make a TextBox hidden of visible based on a bool value databound to the Window its hosted in. What I have just won't compile and I don't understand why. Please help. <TextBlock Grid.Column="2" Text="This order will be sent to accounting for approval" Foreground="Red" VerticalAlignment="Center" FontWeight="Bold" Padding="5"> <TextBlock.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding Path=AllowedToSubmit}" Value="True">

Items collection must be empty before using ItemsSource

[亡魂溺海] 提交于 2019-12-20 03:55:23
问题 If I put a DataTrigger in a simple Listbox I get this runtime exception: Items collection must be empty before using ItemsSource My listbox without datatrigger (no exception): <ListBox ItemsSource="{Binding EdgedBoards}" SelectedItem="{Binding SelEdgedBoard, Mode=TwoWay}" DisplayMemberPath="Name"> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource {x:Type ListBoxItem}}"> <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay,