控件布局模板
我需要一种在页面中布局控件的方法。 让我举例问你。
我有四个不同的操作按钮(编辑、删除等),它们在任何页面上执行相同的操作,但有时我希望它们水平排列,有时垂直排列,具体取决于哪个页面显示它们。
因此,我考虑将所有四个按钮放置在用户控件中,并使用某种模板控件来管理它们的布局。
是否存在这样一个像ListView的模板管理一样灵活的控件?
当然,一个懒惰的解决方案是在一个面板中水平放置四个按钮,在另一个面板中垂直放置另外四个按钮,然后显示/隐藏所需的面板,但我不想有两个按钮实例;我只想要每个按钮的一个实例,但布局不同。
请随意为此添加更多标签。
I need a way to layout controls in a page.
Let me ask you by example.
I have four different action buttons (Edit, Delete, etc..) that do the same actions on any page, but sometimes I want them laid out horizontally and some other times vertically, depending on which page is displaying them.
So I thought of placing all four buttons in a user control and manage their layout using some sort of template control.
Does such a control exist that is as flexible as ListView's template management?
Of course a lazy solution is to place four buttons horizontally in a panel, and another four buttons vertically in another panel, and show/hide the panel that's requested, but I don't want to have two instances of the buttons; I just want one instance of each button, but in different layouts.
Feel free to add more tags to this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这样的事情可以用CSS来实现。我在 CSS 方面很糟糕,但我相信这可行:
HTML
您只需在 div 元素中设置所需的两个 CSS 类(您可以使用 UserControl 包装按钮并将 div 的类映射到 UserControl 的属性)
模板化控件对于如此简单来说太强大了特别是当您不需要更改模板内容时。
Such thing can be achieved with CSS. I'm bad in CSS but I believe this works:
HTML
Two CSS classes you simply set which you need in the div element (you can wrap your buttons with UserControl and map div's class to UserControl's property)
Templated control is to strong for such easy task especially when you do not need to change template content.