Note that there are some explanatory texts on larger screens.

plurals
  1. POWP7: Dynamically adding UIElements to a LongListSelector item
    primarykey
    data
    text
    <p>I'm trying to add <code>UIElement</code>s to a <code>LongListSelector</code> item programmatically. I've created templates for the header, footer, items etc.</p> <p>Right now I'm doing something like this (the list item template):</p> <pre><code>&lt;DataTemplate x:Key="listItemTemplate"&gt; &lt;ContentPresenter Content="{Binding ItemContent}"&gt;&lt;/ContentPresenter&gt; &lt;/DataTemplate&gt; </code></pre> <p>Inside the model, I assisgn the ItemContent to a Grid, on which I'm adding different UI elements. I don't really know if this is the way to do it or if this is even possible on the LongListSelector but when scrolling the list I get a "The parameter is incorrect." exception (at first, everything seems ok and all the elements added look fine). I tried different approaches but none worked and I feel that I'm just randomly trying solutions without a certain idea. Has anyone managed to do this by using a LongListSelector (any suggestions would be greatly appreciated)?</p> <p>The call stack:</p> <p><code> LongListSelectorPOC.dll!LongListSelectorPOC.App.Application_UnhandledException(object sender, System.Windows.ApplicationUnhandledExceptionEventArgs e) Line 102 + 0x5 bytes C# System.Windows.dll!MS.Internal.Error.CallApplicationUEHandler(System.Exception e) + 0x30 bytes<br> System.Windows.dll!MS.Internal.Error.GetXresultForUserException(System.Exception ex) + 0x4d bytes<br> System.Windows.dll!MS.Internal.FrameworkCallbacks.ManagedPeerTreeUpdate(System.IntPtr oldParentElement, System.IntPtr parentElement, System.IntPtr childElement, byte bIsParentAlive, byte bKeepReferenceToParent, byte bCanCreateParent) + 0x6b bytes<br> [External Code] System.Windows.dll!MS.Internal.XcpImports.MeasureOverrideNative(System.IntPtr element, float inWidth, float inHeight, out float outWidth, out float outHeight)<br> System.Windows.dll!MS.Internal.XcpImports.FrameworkElement_MeasureOverride(System.Windows.FrameworkElement element, System.Windows.Size availableSize) + 0x26 bytes System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.Windows.Size availableSize) + 0x7 bytes<br> System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.IntPtr nativeTarget, double inWidth, double inHeight, out double outWidth, out double outHeight) + 0x43 bytes [External Code] System.Windows.dll!MS.Internal.XcpImports.Measure_WithDesiredSizeNative(System.IntPtr element, float inWidth, float inHeight, out float outWidth, out float outHeight)<br> System.Windows.dll!MS.Internal.XcpImports.UIElement_Measure_WithDesiredSize(System.Windows.UIElement element, System.Windows.Size availableSize) + 0x26 bytes<br> System.Windows.dll!System.Windows.UIElement.Measure_WithDesiredSize(System.Windows.Size availableSize) + 0x39 bytes System.Windows.dll!System.Windows.Controls.VirtualizingStackPanel.MeasureChild(System.Windows.UIElement child, System.Windows.Size layoutSlotSize) + 0x42 bytes System.Windows.dll!System.Windows.Controls.VirtualizingStackPanel.GeneratePreviousChild(int childIndex, System.Windows.Size layoutSlotSize) + 0x6f bytes<br> System.Windows.dll!System.Windows.Controls.VirtualizingStackPanel.GeneratePreviousItems(ref double logicalVisibleSpace, ref System.Windows.Size stackDesiredSize, System.Windows.Size layoutSlotSize, bool isHorizontal, bool adjustPositions) + 0x138 bytes<br> System.Windows.dll!System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(System.Windows.Size constraint) + 0x4e1 bytes System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.IntPtr nativeTarget, double inWidth, double inHeight, out double outWidth, out double outHeight) + 0x43 bytes [External Code] </code></p>
    singulars
    1. This table or related slice is empty.
    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