I have a requirement where I need to pop a window up in order to show the detail of the selected tree node. I need it to pop up in a location just to the right of what I selected in the TreeListView.
I figure this could be done using the Mouse Location or the Location relative to the selected node. I haven't been able to get either to work.
My approach is to pop up a simple Tool window at that location. The better solution would be to have an EditTemplate that pops into its own window; but, I'm not sure if that is possible. I have a good EditTemplate (shown) but the user demands that the tree remain very skinny and doesn't want to move things around much because this is a Touch Pad.
I'm open to whatever approach is the easiest code to maintain. Thanks in advance for your help.
Here are my DataTemplates:
<DataTemplate x:Key="TreeNodeTemplate"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="auto"/> <ColumnDefinition Width="auto"/> </Grid.ColumnDefinitions> <Image Grid.Column="0" Source="{Binding Image, Mode=TwoWay}" ToolTip="{Binding Barcode, Mode=TwoWay}"/> <Image Grid.Column="0" Height="20" Width="20" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="-20,0,0,0" Source="{Binding StatusImage, Mode=TwoWay}" ToolTip="{Binding StatusName, Mode=TwoWay}"/> <TextBlock Grid.Column="1" Text="{Binding Name, Mode=TwoWay}" Margin="5" ToolTip="{Binding Description}"/> </Grid></DataTemplate><DataTemplate x:Key="TreeNodeEditTemplate"> <StackPanel Orientation="Horizontal"> <Image Source="{Binding Image, Mode=TwoWay}" VerticalAlignment="Top"/> <Grid Margin="5" Background="Cornsilk"> <Grid.RowDefinitions> <RowDefinition Height="auto"/> <RowDefinition Height="auto"/> </Grid.RowDefinitions> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="125"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="28"/> <RowDefinition Height="28"/> <RowDefinition Height="28"/> <RowDefinition Height="28"/> <RowDefinition Height="auto"/> </Grid.RowDefinitions> <Label Content="ID:" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Center"/> <TextBlock Grid.Column="1" VerticalAlignment="Center" Text="{Binding ID, Mode=TwoWay}"/> <Label Content="Name:" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center"/> <TextBox Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" Text="{Binding Name, Mode=TwoWay}" IsEnabled="{Binding IsEditableStatus}" IsReadOnly="{Binding IsEditableStatus, Converter={StaticResource BoolToOppositeBoolConverter}}"/> <Label Content="Description:" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Right" VerticalAlignment="Center"/> <TextBox Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" Text="{Binding Description, Mode=TwoWay}" IsEnabled="{Binding IsEditableStatus}" IsReadOnly="{Binding IsEditableStatus, Converter={StaticResource BoolToOppositeBoolConverter}}"/> <Label Content="Barcode:" Grid.Column="0" Grid.Row="3" HorizontalAlignment="Right" VerticalAlignment="Center"/> <TextBox Grid.Column="1" Grid.Row="3" VerticalAlignment="Center" Text="{Binding Barcode, Mode=TwoWay}"/> </Grid> <GroupBox Header="Status" Grid.Row="4" Margin="5"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="125"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="28"/> <RowDefinition Height="28"/> </Grid.RowDefinitions> <Label Content="CRUD Status:" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Center"/> <TextBlock Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" Text="{Binding StatusName, Mode=TwoWay}"/> <Label Content="Inspect Status:" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center"/> <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding InspectStatusName, Mode=TwoWay}" VerticalAlignment="Center"/> </Grid> </GroupBox> </Grid> </StackPanel></DataTemplate>