3
您好我想知道如何将我的MainWindow.xaml分成不同的XAML文件?我想将我的风格外包,并在需要时包括它们。我搜索了一些解决方案,发现了一些stackoverflow帖子,但没有人帮助我。如何将MainWindow.xaml分割成单独的文件? - 外包<Style>?
我想实现这样的(伪)
<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>
嗯,我以前试过,但它确实不行。也许我应该给它第二次机会... – TorbenJ 2012-07-15 18:31:44
好吧,它现在的作品。当我尝试之前不知道究竟发生了什么错误。谢谢! :) – TorbenJ 2012-07-15 18:37:20
@TorbenJonas:不客气,很高兴它的工作:) – 2012-07-15 18:39:38