setting content causing ArgumentException

2 posts, 0 answers
  1. Big G
    Big G avatar
    19 posts
    Member since:
    Jan 2013

    Posted 06 Feb 2013 Link to this post

    ok I had a RadTransitionControl that when I click a button I set its content which im guessing should force it to play an animation/transition

    so here it what I do and what happens

    spRunMenu.Visibility = System.Windows.Visibility.Visible;
    rtcRunMenu.Content = spRunMenu;

    spRunMenu is a stackpanel containing buttons.
    rtcRunMenu is the RadTransitionControl

    I get the following message when setting the content.

    System.ArgumentException was unhandled by user code
      HResult=-2147024809
      Message=Value does not fall within the expected range.
      Source=System.Windows
      StackTrace:
           at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
           at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)
           at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)
           at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
           at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
           at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
           at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
           at System.Windows.Controls.ContentControl.set_Content(Object value)
           at MyRun.MainPage.sbShowMenu_Completed(Object sender, EventArgs e)
           at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
           at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)
      InnerException:
  2. Todor
    Admin
    Todor avatar
    778 posts

    Posted 11 Feb 2013 Link to this post

    Hello Gareth,

    Thank you for contacting us.

    This behavior is normal. The Content property is used to display a certain object and place it inside the DataTemplate specified as ContentTemplate. In order to set a StackPanel inside the TransitionControl, you need to use the ContentTemplate property and set a new DataTemplate to it. Here is an example, if you add a template to the resources of the page:
    <DataTemplate x:Name="template1">
        <StackPanel>
            <Button Content="one" Click="Button_Click"/>
            <Button Content="{Binding}"/>
        </StackPanel>
    </DataTemplate>

    You can then use it and set it as ContentTemplate to the TransitionControl:
    transitionControl.ContentTemplate = this.Resources["template1"] as DataTemplate;
    transitionControl.Content = "button 1";

    I hope this information helps. Let me know if I can assist you further.

    Regards,
    Todor
    the Telerik team
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  3. DevCraft banner
Back to Top