Hi,
I have a small problem, when the macro is run, it will look like the image(1):
In the tree view, when I click the right click button on the object to create folder, It should create a new folder under "Example Reference Doc". I can't seem to get the name of the selected TreeViewItem . Because it is in TreeViewItem, I tried to convert it from TreeViewItem to ObjectItem, but it does not convert to ObjectItem.
This is what I inserted in the Window.xaml:
<TreeView ItemsSource="{Binding DocTree}" Name="myTreeView" BorderBrush="White" TreeViewItem.Selected="OnItemSelected" HorizontalAlignment="Left" Height="211" VerticalAlignment="Top" Width="190" Margin="10,10,0,0">
Window.xaml.cs:
public DocWindow()
{
InitializeComponent();
}
private void OnItemSelected(object sender, RoutedEventArgs e)
{
var vm = DataContext as VmDoc;
myTreeView.Tag = e.OriginalSource;
if (myTreeView.SelectedItem != null)
{
TreeViewItem selectedTVI = myTreeView.Tag as TreeViewItem;
MessageBox.Show(selectedTVI.Name); //When i click the item from the treeview, it is showing empty message box.
DocWindow docWindow = new DocWindow(); //so i passed the treeviewitem to the viewmodel
docWindow.DataContext = new VmDoc1(myTreeView.Tag);
}
}
VmDoc.cs:
public class VmDoc1 : Helpers.VmBase
{
public object SelectedTVI;
public static ObjectItem Position;
public VmDoc1(object selectedTVI)
{
SelectedTVI = selectedTVI;
ObjectItem Position = (ObjectItem)selectedTVI;
}
}
Is there any way to read the name of the TreeViewItem ? or is there anyway to convert the TreeViewItem to ObjectItem?