when you are programming in XAML you can make use of behaviors (the declarative way)
first the namespace needed is
xmlns:i="http://schemas.microsoft.com/expression/2009/interactivity"
then your code need to remove the event attached (directly coupled), I tried to rewrite your code for the same
XAML
<TreeView
...
ItemsSource="{Binding TierOneItems}">
<i:Interaction.Behaviors>
<b:RaiseEventBehavior/>
</i:Interaction.Behaviors>
</TreeView >
RaiseEventBehavior.cs
public class RaiseEventBehavior : Behavior<UIElement>
{
protected override void OnAttached()
{
AssociatedObject.KeyUp += (sender, e) =>
{
TreeView topic = sender as TreeView;
string keyValue = e.Key.ToString();
if (keyValue == "Return")
{
//do something here
}
};
}
}
The above is just an exmple based on your query, feel free to adjust it your on way. This approach is best suited for XAML, leverage behaviors and see the true beauty of XAML