开发者

ItemsControl how to find controls used for display items in the list

I am writing a custom ItemsControl to display a list of item. The items are displayed using MyCustomItemView control. Here is the template in my generic.xaml:

 <Style TargetType="{x:Type MyCustomItemsControl}">
   <Setter Property="Template">
     <ControlTemplate TargetType="{x:Type MyCustomItemsControl}">
          开发者_开发技巧<Grid>
                   <ItemsPresenter/>
           </Grid>
     </ControlTemplate >
  </Setter>
<Setter Property="ItemTemplate">
 <Setter.Value>
     <DataTemplate>
        <MyCustomItemView/>
     </DataTemplate>
   </Setter.Value>
</Setter>

</Style>

In MyCustomItemsControl I want to subcribe to each MyCustomItemView's MoveEnter event. How can I do that?

I tried to use VisualTreeHelper to find MyCustomItemView controls, but the problem is I don't know when to do it because I can't find any override method in ItemsControl that will be called when all children controls have been created.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜