.net - WPF Equivalent of OwnerDraw -


in winforms application maintain have tree control several thousand nodes in it. each node owner drawn custom, dynamically generated, icon (each icon unique). i'm thinking converting application in wpf, don't know how handle tree view. know standard way of doing in wpf use template each item image control icon content, i'm worried performance if bind several thousand dynamically created images. ownerdraw don't have store icon, can generate , paint when nodes actual visible.

is there standard way of handling scenario in wpf?

screenshots of current application can seen here give idea of i'm dealing with.

a correct tree implementation virtualize items, meaning displayed bound data , rendered. knowing this, generate image dynamically when it's needed.

view side, item template:

<datatemplate>   <image source="{binding image}" /> <datatemplate> 

model side :

private imagesource _image;  public imagesource image {   { return _image ?? (_image = createimage()); } }  private imagesource createimage() {    // load image dynamically here    // if you're creating scratch, writeablebitmap might } 

this code caches image _image field. if don't need it, can re-create each time image accessed (be careful not access property often).


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -