datatrigger

Can i call a function via DataTrigger (XAML)?

浪尽此生 提交于 2021-02-18 17:08:23
问题 I have a function in .xaml.cs which i wanted to call: .xaml.cs private void treeView_SelectedItemChanged(object sender, EventArgs e) { //treeView.ScrollToCenterOfView(sender as TreeViewItem); } like from this post: Make ListView.ScrollIntoView Scroll the Item into the Center of the ListView (C#) Answer 1 But i dont use the SelectedItem, my approach would be like: XAML: <Style.Triggers> <DataTrigger Binding="{Binding Path=IsActive}" Value="true"> // ###call this function </DataTrigger> </Style

DataTrigger is not binding to a global static property? [duplicate]

血红的双手。 提交于 2021-01-29 14:31:15
问题 This question already has answers here : Static binding doesn't update when resource changes (2 answers) Closed 2 years ago . I am using DataTrigger to change the background color in WPF. I have a property in Globals Class which have a true and false value. I check a lot of code from Stackoverflow but I didn't get it working. Please check. <Grid Height="350" Width="525" Name="gridTesting"> <Grid.Style> <Style TargetType="{x:Type Grid}"> <Style.Triggers> <DataTrigger Binding="{Binding

Animation inside DataTrigger won't run a second time

自闭症网瘾萝莉.ら 提交于 2020-03-26 08:04:13
问题 This is the code: <Grid> <Ellipse Fill="Turquoise" HorizontalAlignment="Left" Height="100" Stroke="Black" VerticalAlignment="Top" Width="100"> <Ellipse.Style> <Style TargetType="Ellipse"> <Style.Setters> <Setter Property="Ellipse.RenderTransform"> <Setter.Value> <TranslateTransform X="0" Y="50"/> </Setter.Value> </Setter> </Style.Setters> <Style.Triggers> <DataTrigger Binding="{Binding ElementName=rectRight, Path=IsMouseOver}" Value="True"> <DataTrigger.EnterActions> <BeginStoryboard>

Trouble setting a DataTrigger in WPF

ε祈祈猫儿з 提交于 2020-02-03 05:13:13
问题 I have a ComboBox and a Button on my main view, and I want to apply a style to the button such that when the combobox index is set to 1, the button becomes visible (initially it's hidden). This is my XAML code: <Grid> <StackPanel Orientation="Vertical" Margin="10"> <ComboBox Name="comboBox"/> <Button Name="myBtn" Content="Hello" Visibility="Hidden"> <Button.Style> <Style TargetType="{x:Type Button}"> <Style.Triggers> <DataTrigger Binding="{Binding ElementName=comboBox, Path=SelectedIndex}"

'The member “Opacity” is not recognized or is not accessible.' Why can't I set the opacity?

只谈情不闲聊 提交于 2020-01-30 05:48:11
问题 I would like to use a DataTrigger to modify the opacity of my button. <Button x:Name="StartTreatment" Grid.Column="3" Width="160" Height="30" Content="{x:Static resources:UserMessages.TrcsConsoleViewModel_LoadWfSequence_StartProcedure}" IsEnabled="{Binding CanStartProcedure}" Visibility="{Binding CanStartPatientTreatment, Converter={StaticResource BooleanToVisibility}}" > <Button.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding CanStartProcedure}" Value="False"> <Setter Property

Dynamically set event handler using DataTrigger

南楼画角 提交于 2020-01-14 07:42:05
问题 iv'e got several itemscontrols which i need to attach an event handler for their PreviewMouseLeftButtonDown event only when a certain condition is met . iv'e designed a style for my controls with a datatrigger ,i checked out it's bindings and tried it out with a regular property setter for the BorderThickness Property just to see that the datatrigger works . (It does..) how can i apply my datatrigger to attach an event handler when the condition of the datatrigger is met using an event setter

Button blinking on Datatrigger

六眼飞鱼酱① 提交于 2020-01-14 05:34:08
问题 I would like to have a button that blinks/animate when triggered by DataTrigger. I want to animate the button's background. Below is my xaml code. <Window.Resources> <Style x:Key="ButtonStyle" TargetType="{x:Type Button}"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext.Notification}" Value="True"> <DataTrigger.EnterActions> <BeginStoryboard Name="StartBlinking"> <Storyboard> <ColorAnimation Storyboard.TargetProperty="

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

你。 提交于 2020-01-13 10:34:09
问题 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

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

一曲冷凌霜 提交于 2020-01-13 10:34:06
问题 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

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

不打扰是莪最后的温柔 提交于 2020-01-13 10:33:34
问题 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