将2个itemscontrol放在一个datatemplate中并在XAML中放置边框 [英] Placing 2 itemscontrol inside one datatemplate and border in XAML
本文介绍了将2个itemscontrol放在一个datatemplate中并在XAML中放置边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是我的xaml结构的简短概述,我无法弄清楚如何从一个DataTemplate中的2个不同绑定中获得2个ItemsControl,以及Grid中的两个行中的Border.
Here is short overview of my xaml structure, and I cant figure out how to have 2 ItemsControl from 2 different bindings inside one DataTemplate and Border for both Rows inside Grid.
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ItemsControl Grid.Row="0" x:Name="AdditionalInfoControl" ItemsSource="{Binding VisibilityCollection}" Grid.ColumnSpan="2">
<DataTemplate>
<Border BorderBrush="DimGray" CornerRadius="8,8,8,8" BorderThickness="2,2,2,2" Margin="5,2,3,3" Background="WhiteSmoke">
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<ItemsControl Grid.Row="1" x:Name="Details" ItemsSource="{Binding DetailsCollection}" Grid.ColumnSpan="2">
<DataTemplate>
<Border BorderBrush="DimGray" CornerRadius="8,8,8,8" BorderThickness="2,2,2,2" Margin="5,2,3,3" Background="WhiteSmoke">
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate></ItemsControl>
</Grid>
我尝试过:
上面的代码就是我尝试但我不知道如何解决这个问题。
What I have tried:
Code above is what I tried but I dont have idea how to fix this issue.
推荐答案
你需要另一个布局面板之间。例如。 DataTemplate-> Border-> StackPanel-> ItemsControls
你对不同的绑定的意思是什么?不同的DataContexts?没有你的代码看起来不像这样。所以我没有得到绑定的错误 - 看起来没问题 - 只需将它们放在DataTemplate中......
You need another layout panel in between. eg. DataTemplate->Border->StackPanel->ItemsControls
What you mean with "different bindings"? different DataContexts? No your Code doesn't look like this. So I don't get what could be wrong with the bindings - Looks ok To me - just put them together inside the DataTemplate...
这篇关于将2个itemscontrol放在一个datatemplate中并在XAML中放置边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文