我有一个自定义控件,我是根据我创建并导出到xaml的表达式设计创建的。我已经在其中添加了ListBox控件的绑定itemtemplate / datatemplate。它似乎不是渲染多次和/或它在同一个地方呈现每个项目(有点像相同的x,y坐标。
在我看来,这应该是一个简单的过程。如果我用文本块填充datatemplate,它将在垂直列表中生成几个文本块。我希望如果我用我的自定义控件替换textblock我应该在垂直列表中获得一些自定义控件。
这不是预期的行为,还是列表框似乎只呈现单个用户控件?在这两种情况下,我都使用相同的数据作为列表框。
<telerik:ListBox x:Name="PeopleList" Grid.Row="1" >
<telerik:ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<custom:ExecSelector Height="100" Width="100" x:Name="ExecSelector" FullName="{Binding City}"></custom:ExecSelector>
</Grid>
</DataTemplate>
</telerik:ListBox.ItemTemplate>
</telerik:ListBox>
People = new List<PersonViewModel>();
PersonViewModel person2 = new PersonViewModel()
{
Name = "Austin Weise",
City = "Texas",
Email = "austin@build1.ca",
Position = "Techincal Director",
Bio = "Programmer"
};
PersonViewModel person = new PersonViewModel()
{
Name = "Ian House",
City = "Vancouver",
Email = "Ian@build1.ca",
Position = "Creative Director",
Bio = "Designer"
};
People.Add(person2);
People.Add(person);
PeopleList.DataContext = this;
PeopleList.ItemsSource = People;
除非自定义控件需要UI元素,否则应提供足够的可视化效果。
答案 0 :(得分:0)
根据您当前对问题的描述:
Top
和Left
属性上添加任何值。除非你有更多详细信息,否则我可以抛弃所有猜测。