我在资源字典中定义了一个列表框项的样式。我想在列表框的cs文件中使用这个样式:
我尝试了以下操作,但是它给了我一个null值,CustomListBoxItemStyle是样式的名称:
public class CustomListBox : ListBox
{
public CustomListBox()
{
this.ItemContainerStyle = Application.Current.Resources["CustomListBoxItemStyle"] as Style;
}
}
这里没有XAML。
如何实现这个功能?