如何为我创建的对象提供高度属性,以便在添加到列表框时它会自动采用该高度?
我试图为我创建的对象赋予高度属性,因此当我将其添加到 ListBox
时,ListBox
会获取该高度并占据我需要它占据的高度。 谢谢
public class mmrequisicion : DependencyObject
{
public static readonly DependencyProperty HeightProperty;
public double Height
{
//get
//{
// return 23;//(double)GetValue(HeightProperty);
//}
set
{
SetValue(HeightProperty, 23);
}
}
}
I am trying to give height property to an object I created so when I add it to a ListBox
, the ListBox
gets that height and it occupies the height I need it to occupy.
Thanks
public class mmrequisicion : DependencyObject
{
public static readonly DependencyProperty HeightProperty;
public double Height
{
//get
//{
// return 23;//(double)GetValue(HeightProperty);
//}
set
{
SetValue(HeightProperty, 23);
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该创建一个 DataTemplate 或 ItemTemplate 并将容器的 height 属性绑定到“mmrequisicion”的 Height 属性。
You should create a DataTemplate or ItemTemplate and bind the height property of your container to the Height property of 'mmrequisicion'.