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.Triggers>
I dont have any Idea how to raise this function by change of the DataModel. In every Tutorial i have gooled they do it via Event/Command.
Thx
Just to add another slightly hacky option for these scenarios.
Not quite a Trigger, but you can utilise the generic FrameworkElement.Tag property to set up a binding for the property you want to watch, and then run a callback when it changes.
eg:
<DataTemplate>
<StackPanel Tag="{Binding IsActive, NotifyOnTargetUpdated=True}"
TargetUpdated="CodeBehindMethodToCall">
<!-- snip rest of template -->
</StackPanel>
<DataTemplate>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With