更新时间:2022-06-04 02:44:57
您可以这样做
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Assets/StyleDictionary.xaml"/>
</ResourceDictionary.MergedDictionaries>
<!--<ObjectDataProvider x:Key="SAG_POK" ObjectType="{x:Type or:SAG_POK}" />-->
<local:MainViewModel x:Key="SAG_POK" />
</ResourceDictionary>
</Application.Resources>
<StackPanel DataContext="{Binding Source={StaticResource SAG_POK}}">
<TextBlock Name="ValgtSag" Text="{Binding ToStringProperty}"/>
</StackPanel>
App.Current.Resources["SAG_POK"].SelectedItem = SagSelectedItem;
MainViewModel是孔应用程序中的主视图模型:-)
MainViewModel is yout main view model :-) in the hole application
希望这会有所帮助