Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- You can only retrieve your UserControl by name from the template, so you'll need to supplement your UserControl with the following method:
- public ToggleButton FindToggleButton()
- {
- //since the ToggleButton inside the control has a name ("PART_ToggleButton"), we can simply access it via a field of the same name
- return PART_ToggleButton;
- }
- Just put this method in your control's code-behind.
- Then you need to modify the method retrieving the ToggleButton from the ListView:
- ...
- //first we retrieve the GroupItem control associated with current second-level group
- var container = listView.ItemContainerGenerator.ContainerFromItem(leagueGroup) as GroupItem;
- //then we find the named FavouriteControl inside the template
- var favouriteControl = container.Template.FindName("PART_FavouriteControl", container) as FavouriteControl;
- var toggleButton = favouriteControl.FindToggleButton();
- Note that to avoid confusion I used the name "PART_FavouriteControl", so you need to update your GroupItem template accordingly, so that it has:
- <LSControls:FavouriteControl x:Name="PART_FavouriteControl" (...)>
Advertisement
Add Comment
Please, Sign In to add comment