Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF Custom Control derived from ItemsControl fails to display bound data
    primarykey
    data
    text
    <p>I've created a custom control called MovableItemsControl, inheriting from ItemsControl, in order to override the <em>GetContainerForItemOverride()</em> method. My problem is that none of the objects in the bound collection are displaying. Currently, I'm binding to an OberservableCollection of strings, and I can see that they're in <em>ItemsSource</em> when I look through the debugger. </p> <p>The custom control is shown below: </p> <pre><code>public class MovableItemsControl : ItemsControl { static MovableItemsControl() { DefaultStyleKeyProperty.OverrideMetadata(typeof(MovableItemsControl), new FrameworkPropertyMetadata(typeof(MovableItemsControl))); } /// &lt;summary&gt; /// Wraps each content object added to the ItemsControl in a NodeWrapper /// &lt;/summary&gt; protected override DependencyObject GetContainerForItemOverride() { NodeWrapper nodeWrapper = new NodeWrapper(); return nodeWrapper; } protected override bool IsItemItsOwnContainerOverride(object item) { return item is NodeWrapper; } } </code></pre> <p>NodeWrapper is a UserControl consisting of a custom control derived from Thumb (MoveThumb) and a Label (the Label is just for testing).</p> <pre><code> &lt;Style TargetType="{x:Type local:MovableItemsControl}"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type local:MovableItemsControl}"&gt; &lt;Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"&gt; &lt;/Border&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload