简体   繁体   中英

dynamic resource binding to list?

<Window.Resources>
    <DataTemplate x:Key="key_t"/>
</Window.Resources>

<ListBox />

How do i bind window.resource dynamically to listbox ?

Since you specifically asked for dynamic binding:

<ListBox ItemTemplate="{DynamicResource key_t}"></ListBox>

However, I don't see why you'd need dynamic binding in your example. Thus, I'd suggest to use static binding instead:

<ListBox ItemTemplate="{StaticResource key_t}"></ListBox>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM