问题标签 [itemspresenter]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
308 浏览

wpf - Datagrid - ItemsPresenter - 垂直滚动查看器

您好 Stackoverflow 成员,

我是新来的!对不起,一个简短的问题。但我需要你的帮助!我有一个 2000 行的 Datagrid。(按 CustomerNbr 分组)

vb.net
Dim 分组为新 ListCollectionView(full_list)
grouped.GroupDescriptions.Add(New PropertyGroupDescription("CustNbr"))
Datagrid.ItemsSource = grouped

这段代码运行良好

但是当我在 ItemsPresenter 添加一个滚动查看器时,我得到一个错误:

错误来了,当我制作第二个分组的 custnbr 屏幕时

错误:invalidOperationExeption 未处理

我需要 ScrollViewer,因为我在 CustNbr 上有很多发票。问题出在扩展器中。在 Expander.Content 中,不支持垂直 ScrollViewer 之类的......

有谁能够帮我?

0 投票
2 回答
302 浏览

wpf - 从 itemsControl 继承 - 如何更改项目的类型?

我正在努力改进ListView。这主要与ListViewItem课堂上的变化有关。所以我继承了两者,创建了两个服装控件:

问题是现在我希望NestedListView's<ItemsPresenter/>呈现NestedListViewItems 而不是常规的ListViewItems。我如何实现这一目标?

(我几乎不知道是如何 <ItemsPresenter/>工作的。所以关于该领域的任何解释都可能会有所帮助)。

0 投票
1 回答
1092 浏览

c# - How to style items in the ItemsPresenter of a custom ItemsControl?

I am trying to create a custom ItemsControl, which shows RadioButtons or Checkboxes and applies styles to those items automatically.

This is what I have right now:

Custom ItemsControl:

Styles:

And I am using it like this:

Everything is working fine, except styling the individual items. In this case I am trying to add a margin to the radiobuttons. I am aware I could add the margins to each and every item manually, but I'm trying to avoid this.

I have tried putting the styles in ItemsPresenter.Resources of the main style and I have tried putting it in StackPanel.Resources of the ItemsPanelTemplate. Both of those options are not working, the styles are not applied.

Any ideas why this is not working?

0 投票
2 回答
540 浏览

wpf - 在继承自 ItemsPanel 的用户控件中结合 Viewbox、Canvas、ItemsPanelTemplate 和 ItemsPresenter

我想扩展ItemsPanel,以便我可以显示一个“分层”视觉结构,其中我有一个已知大小和大量覆盖的“框架”,类似于制图或插图应用程序。

我遇到的问题是找出如何组合事物以使一切按预期工作。到目前为止我做了什么:

  • 创建了一个继承自的控件ItemsControl
  • 在控件内部,放置一个Viewbox包含一个ItemsPresenter
  • 在控件的资源中,创建了一个针对其自身类型的样式,将 设置ItemsPanel为由Canvas.

所以我希望,在 Live Tree Inspection 下,我应该在嵌套结构中看到:

  • LayerContainer(我的控件的类名)
    • 视图框
      • 项目演示者
      • 帆布
        • 项目1
        • 项目2

相反,我看到的是:

  • 层容器
    • 边界
      • 项目演示者
      • 帆布
        • 视框
        • 项目1
        • 项目2

所以问题是 ViewBox 包含在 Canvas 中,与渲染的项目一起。

那么我的问题是:如何以嵌套顺序为 ItemsPresenter->Viewbox->Canvas->Items 的方式构建我的 LayerContainer 控件?

这是我的控件(名称实际上不是LayerContainer

0 投票
0 回答
241 浏览

c# - WPF 中的多个 ItemsPresenter

我正在做类似于WPF User control 中的 Multiple Content Presenters 的事情。

我正在为条件 if 语句创建一个可视化小部件,并且我希望同时存在真假内容。它与原始帖子的不同之处在于我希望能够在真假内容中有多个项目。虽然我可以绑定 ContentPresenter 的 Content 属性,但 ItemsPresenter 没有类似的东西可以绑定。

有没有办法可以在控件中构建(不仅仅是让调用 XAML 将其包装在 Grid/StackPanel/等中)?

0 投票
0 回答
221 浏览

wpf - 具有多个 ItemsPresenter 的 WPF ComboBox

我需要创建一个带有 2 个 ItemsPresenter 的自定义 ComboBox,但我不知道如何设置 ItemsPresenter 在哪里添加和删除项目。

我试图获取 ItemsPresenter:

但我不知道如何获取 Items 集合。

这就是我修改 Popup 部分的方式:

有 2 个 ItemsPresenter(ItemsPresenterAlbum、ItemsPresenterSlide)。如何将项目添加到特定的 ItemsPresenter?使用 Items.Add() 它只添加到第二个 ItemsPresenter。