XAML error: “The property 'VisualTree' is set more than once”

前端 未结 1 1867
囚心锁ツ
囚心锁ツ 2021-02-12 23:05

I\'m trying to put two Grids in a DataTemplate.

I\'m getting the following error with my code shown below.

Error: \"The property \'VisualTree\' is

相关标签:
1条回答
  • 2021-02-12 23:36

    A data template can only have one visual tree but you are defining two grids. If you want the two grids to appear next to each other or one below the other, wrap them in a StackPanel and set the property Orientation accordingly.

    <DataTemplate>
       <StackPanel Orientation="Vertical">
          <Grid>[...]</Grid>
          <Grid>[...]</Grid>
       </StackPanel>
    </DataTemplate>
    
    0 讨论(0)
提交回复
热议问题