This question is locked. New answers and comments are not allowed.
I need to be able to start and stop a usercontrol or storyboard background from code for a
particular radtreeviewitem when I want to alert the user that something has
happened for a contact.
I have a databound radtreeview for a contact list.
Inside the datatemplate I have a usercontrol I have created (ContactBackgroundControl) which is just a stackpanel with a background that goes from transperent to a color and back again.
When I try the code below, I get an error "Reference is not a valid visual DependencyObject" refering to when I do the FindChildByType call searching for the type "ContactBackgroundControl". I have also tried the type "UserControl", but that results in the same exact error.
Is there any way to get a reference to the particular usercontrol inside the radtreeview item so I can start or stop the usercontrol storyboard? Or is there some better method to pull off an effect like this?
Thanks!
I have a databound radtreeview for a contact list.
| <!-- data template for the Contact object--> |
| <telerik:HierarchicalDataTemplate x:Name="ContactTemplate" telerik:ContainerBinding.ContainerBindings="{StaticResource BindingsCollection}" > |
| <local:ContactBackgroundControl x:Name="ContactBlinker" > |
| <StackPanel x:Name="ContactContent" Orientation="Horizontal"> |
| <telerikNavigation:RadContextMenu.ContextMenu> |
| <telerikNavigation:RadContextMenu x:Name="ContactContextMenu" ItemClick="RadMenuItem_Click" Opened="ContactContextMenu_Opened"> |
| <telerikNavigation:RadMenuItem Header="Send IM" Tag="{Binding SIPURL}" /> |
| <telerikNavigation:RadMenuItem Header="Start Livemeeting" Tag="{Binding SIPURL}" /> |
| </telerikNavigation:RadContextMenu> |
| </telerikNavigation:RadContextMenu.ContextMenu> |
| <Image Source="{Binding CurrentPresence, Converter={StaticResource PresenceConverter}}" Margin="0, 0, 5, 0"/> |
| <TextBlock Text="{Binding ContactName}" Margin="0, 0, 0, 0" /> |
| </StackPanel> |
| </local:ContactBackgroundControl> |
| </telerik:HierarchicalDataTemplate> |
Inside the datatemplate I have a usercontrol I have created (ContactBackgroundControl) which is just a stackpanel with a background that goes from transperent to a color and back again.
When I try the code below, I get an error "Reference is not a valid visual DependencyObject" refering to when I do the FindChildByType call searching for the type "ContactBackgroundControl". I have also tried the type "UserControl", but that results in the same exact error.
| public void SetContactBlinking(string sipuri) |
| { |
| //iterate thorugh each group, and each groups contacts in the treeview |
| foreach (ContactGroup group in OCSContactsTreeView.Items) |
| { |
| int ContactIndex = 0; |
| foreach (Contacts_ contact in group.Contacts_) |
| { |
| //if the contact matches the sent sipuri, get the treeview item and set blinking |
| if(contact.SIPURL == sipuri) |
| { |
| RadTreeViewItem TVItem = (RadTreeViewItem)(OCSContactsTreeView.ItemContainerGenerator.ContainerFromIndex(ContactIndex)); |
| //get the instance of the contactbackgroundcontrol and start the storyboard |
| ContactBackgroundControl Control = TVItem.Template.FindChildByType<ContactBackgroundControl>(); |
| Control.BlinkContact.Begin(); |
| } |
| ContactIndex++; |
| } |
| } |
| } |
Is there any way to get a reference to the particular usercontrol inside the radtreeview item so I can start or stop the usercontrol storyboard? Or is there some better method to pull off an effect like this?
Thanks!