如何为我创建的对象提供高度属性,以便在添加到列表框时它会自动采用该高度?

发布于 2025-01-01 02:33:11 字数 447 浏览 3 评论 0原文

我试图为我创建的对象赋予高度属性,因此当我将其添加到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生活了然无味 2025-01-08 02:33:11

您应该创建一个 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'.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文