我想创建一个树控件,当用户单击树控件中的元素时,将使用其属性填充属性网格。
我已经创建了一个树形控件作为用户控件,我正在使用Jaime Oliveras的属性网格。我在WPF窗口上都有,但我似乎无法弄清楚如何使两者相互通信。
主窗口上的XAML是:
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:advanced="clr-namespace:OptionsStrategyTree.ViewModel"
xmlns:local="clr-namespace:OptionsStrategyTree.ViewModel"
xmlns:Controls="clr-namespace:System.Windows.Controls"
x:Class="OptionsStrategyTree.MainWindow"
mc:Ignorable="d"
Title="MainWindow" Height="400" Width="500">
<Grid>
<local:UserStrategyTree HorizontalAlignment="Left" Margin="18,6,0,13"
Width="195" Height="340" />
<Controls:WpfPropertyGrid x:Name="StrategyTreePropertyGrid"
HorizontalAlignment="Left" Height="340" Margin="233,6,0,0"
VerticalAlignment="Top" Width="239"/>
</Grid>
</Window>
当控件全部在同一个XAML窗口上时,我已经很好地使用了这个属性网格。但是,当我将树控件创建为用户控件时,它在自己的XAML空间中是一个独立的实体,似乎与其他所有内容隔离开来。有没有办法连接这两个?