嗨,我想知道如何将我的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>
Run Code Online (Sandbox Code Playgroud)
H.B*_*.B. 10
创建XAML ResourceDictionary
文件,包括它们:
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="./Styles/TextBlockStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
<!-- other resources here -->
</ResourceDictionary>
</Window.Resources>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
949 次 |
最近记录: |