私はいくつかの同様のスレッドがあることを知っていますが、私はまだ最良の実装がわかりません。
コードは自明である必要があります-そこでコメントを確認してください。そのVIewModelにアクセスするための最良の方法。
part:FontSearchBoxは、ViewModelのないUserControlです-コマンドを実行する必要がある検索用のTextBoxを保持しているだけです。
ありがとう、感謝します。
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="35" />
<RowDefinition Height="90" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<part:MainWindowControls Grid.Row="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Source="/Typesee;component/Resources/window_logo.png" Width="156" Height="45" Grid.Column="0" VerticalAlignment="Top" RenderOptions.BitmapScalingMode="NearestNeighbor" />
<!-- THIS TEXTBOX NEEDS TO CALL A COMMAND (SearchCommand.Execute(string)) Which resides in the fontTreeViewControl's ViewModel (FontTreeViewModel) -->
<part:FontSearchBox Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,12,10" Width="250" DataContext="{Binding ElementName=fontTreeViewControl, Path=DataContext}" />
</Grid>
<vw:FontTreeView x:Name="fontTreeViewControl" Grid.Row="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
</Grid>