public static bool TrySetState(TempVisualStateGroup group, string stateName, IControl control)
        {
            //If state is already set, we can move on
            //Assumes Pseudoclasses aren't modified outside of VSM
            if (group.ActiveState != null && group.ActiveState.Equals(stateName, StringComparison.OrdinalIgnoreCase))
            {
                return(true);
            }

            try
            {
                if (group.ActiveState != null)
                {
                    ((IPseudoClasses)control.Classes).Remove(group.ActiveState);
                }
                group.ActiveState = stateName;
                if (stateName != null)
                {
                    ((IPseudoClasses)control.Classes).Add(group.ActiveState);
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
        /// <summary>
        /// Gets a VisualStateGroup for a control
        /// </summary>
        /// <returns>True if group already existed, False if group was created</returns>
        public static bool TryGetGroup(IList <TempVisualStateGroup> groups, string groupName, out TempVisualStateGroup group)
        {
            for (int i = 0; i < groups.Count; i++)
            {
                if (string.Equals(groupName, groups[i].GroupName, StringComparison.OrdinalIgnoreCase))
                {
                    group = groups[i];
                    return(true);
                }
            }

            group = new TempVisualStateGroup()
            {
                GroupName = groupName
            };
            return(false);
        }