When using ItemsControl ItemsControl.ItemsPanel is set to Canvas, ContenPresenter comes in and break my Canvas properties on the children [WPF]

后端 未结 3 1896
故里飘歌
故里飘歌 2020-12-31 05:07

I am using an ItemsControl where the ItemsPanel is set to Canvas (see this question for more background information). The ItemsControl is performing as I want, and it works

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-31 05:31

    there are several solutions coming to my mind:

    1. use a layout/rendertransform instead of the attached property
    2. use margin instead of the attached property
    3. derive from ItemsControl, and override the behavior how the child containers are generated. (GetContainerForItemOverride, IsItemItsOwnContainerOverride). This article is explaining quite nicely how it works: http://drwpf.com/blog/2008/07/20/itemscontrol-g-is-for-generator/

提交回复
热议问题