开发者

Can you change the style of an object based on a property within the object in WPF?

开发者 https://www.devze.com 2023-01-02 17:06 出处:网络
I have a class for message, and the objects are being displayed in a ListBox and there\'s a property for the message based on whether it\'s sent to or from the user.Is there a way to create two differ

I have a class for message, and the objects are being displayed in a ListBox and there's a property for the message based on whether it's sent to or from the user. Is there a way to create two different styles and change t开发者_StackOverflowhem depending on this property?


You should create a DataTemplate for the type of the item you're displaying. In that DataTemplate, you use a DataTrigger to control how the item varies in appearance depending upon a property of the object.


Yes. use dynamic resource link text

0

精彩评论

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