xamlオブジェクトにアクセスする必要があるメソッドがあります。wpf ViewModelからLoadComponent()によって作成されたxamlオブジェクトにアクセスする
私はこれがMVVMの慣習に違反していることは知っていますが、データバインディングを使用するだけの理由があります。
これは私がツリービューを移入する必要があるのViewModelを持っているXAMLコード
<Page x:Class="RainforestExcavator.cs1.UI.TestCasePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:RainforestExcavator.cs1.UI"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
Title="TestCasePage">
<Grid>
<TreeView x:Name="treeView"/>
</Grid>
です。
public class TestSuiteViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public TestSuiteViewModel()
{
LoadData();
LoadCommand();
Messenger.Messenger.Default.Register<string>(this, OnPlanPopulated,"PlanUpdated");
}
private void OnPlanPopulated(string selectedPlan)
{
methodThatWillPopulateTheTreeView(selectedPlan, treeView)
}
}
selectedPlanが入力されたときに "OnPlanPopulated"メソッドをトリガーするメッセンジャークラスがあります。
私はこれを行うのに苦労しています。
つまり、Initialize()で作成されたTestCasePageオブジェクトにアクセスできません。
これを行う方法はありますか?
郵便番号。 – sthotakura