从ListBox派生一个自定义类型
重写GetContainerForItemOverride(),返回你的自定义ListBoxItem的实例
大概就是这样吧:
public class MyListBox:ListBox
{
protected override DependencyObject GetContainerForItemOverride()
{
return new MyListBoxItem();
}
}
重写GetContainerForItemOverride(),返回你的自定义ListBoxItem的实例
大概就是这样吧:
public class MyListBox:ListBox
{
protected override DependencyObject GetContainerForItemOverride()
{
return new MyListBoxItem();
}
}
解决方案 »
- 怎么让C#函数返回值为某个对象?如返回 Ipaddress类
- 菜鸟求助
- GridView 倒序 问题
- 请教一高难度的函数转换
- 不在Paint事件实现对控件绘制???
- OleDB 方式导出Excel模板,数据如何从第一行开始?
- PrintDocument 组件
- 程序打包
- C#怎么根据时间来获取最新的值
- 輸入第一個textbox後,焦點自動跳入下一個textbox並且聚焦的textbox顏色反藍,輸入數字後textbox自動接收輸入值,輸入滿字符自動跳下一textbox並且聚焦的textbox顏色反藍,同理進行輸入。
- 求教一个关于return问题
- 求问::子线程强制中止后,下次新实例中,文件流显示无法创建????
改为你自己的类型即可
<Style TargetType="local:MyListBoxItem">
这里的local是当前项目的命名空间,定义方式不用我说了吧。
<Style x:Key="ListBoxStyle1" TargetType="{x:Type local:MyListBox}">
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style TargetType="local:MyListBoxItem">
...
...
</Style>
</Setter.Value>
</Setter>
</Style>