0

Is there any simple way how to pass Url value in TextBlock_IsMouseDirectlyOverChanged event without showing in on UI?

<TreeView Grid.Row="1" ItemsSource="{Binding Nodes}" >
    <TreeView.ItemTemplate>
        <HierarchicalDataTemplate ItemsSource="{Binding Path=Nodes}">
            <TextBlock IsMouseDirectlyOverChanged="TextBlock_IsMouseDirectlyOverChanged">
                <TextBlock.Text>
                    <MultiBinding StringFormat="{}{0}">
                        <Binding Path="Name" />
                        <Binding Path="Url" />
                    </MultiBinding>
                </TextBlock.Text>
                <TextBlock.ToolTip>
                    <ToolTip Visibility="Collapsed">
                        <TextBlock Text="{Binding Url}"></TextBlock>
                    </ToolTip>
                </TextBlock.ToolTip>
            </TextBlock>
        </HierarchicalDataTemplate>
    </TreeView.ItemTemplate>
</TreeView>

DataModel:

public class Node
{
    public string Name { get; set; }

    public string Url { get; set; }

    public ObservableCollection<Node> Nodes { get; set; }
}
Il Vic
  • 5,576
  • 4
  • 26
  • 37
A191919
  • 3,422
  • 7
  • 49
  • 93
  • Could you not do `(Node)(((TextBlock)sender).DataContext).Url`?, Or as suggested here https://stackoverflow.com/questions/2006507/add-parameter-to-button-click-event, you could use the `Tag` property as a parameter – Alfie May 07 '19 at 11:28
  • @Alfie, You are right! Please post answer and i will accept it. – A191919 May 07 '19 at 11:34

1 Answers1

2

You could do:

 (Node)(((TextBlock)sender).DataContext).Url

Or as suggested here Add parameter to Button click event, you could use the Tag property as a parameter.

Alfie
  • 1,903
  • 4
  • 21
  • 32