您好,我想知道如何将我的MainWindow.xaml拆分成不同的xaml文件? 我想外包我的样式,并在需要时包含它们。 我搜索了一些解决方案并找到了一些stackoverflow帖子,但没有一个能帮助我。
我想实现类似于以下内容的东西(伪代码)
<Window x:Class="MyApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MyApp"
Title="MyApp" Height="350" Width="525">
<Window.Resources>
//Import external xaml file with textbox style here
//instead of:
<Style TargetType="{x:Type TextBox}">
<Style.Triggers>
//add code here
</Style.Triggers>
</Style>
</Window.Resources>
<StackPanel>
<TextBox Width="60"/>
<Button Content="Button" Height="23" Name="button1" Width="75" />
</StackPanel>