我是一名有用的助手,可以帮助您翻译文本。
我有一个包含一些按钮和ItemsControl的UserControl。在使用此控件的窗口中,我想为此ItemsControl设置ItemTemplate。
我该如何实现这个功能?
UserControl:
<UserControl x:Class="WizardTest.WizardControl"
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"
x:Name="thisControl"
Loaded="OnLoaded"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<DockPanel>
<UniformGrid DockPanel.Dock="Bottom" Columns="4">
<Button>Cancel</Button>
<Button>< Back</Button>
<Button>Next ></Button>
<Button>Finish</Button>
</UniformGrid>
<ItemsControl DockPanel.Dock="Left" ItemsSource="{Binding WizardPages, ElementName=thisControl}">
</ItemsControl>
</DockPanel>
窗口:
<Window x:Class="WizardTest.EigenesWizardWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WizardTest"
Title="Wizard Window" Height="300" Width="300">
<local:WizardControl WizardPages="{Binding WizardPages}">
</local:WizardControl>
ItemTemplate
属性,当设置该属性时,它会设置嵌入的 ItemControl 的 ItemTemplate 属性。 - Clemens