Focus Restoring in Busy Indicator

3 posts, 0 answers
  1. Hareesh
    Hareesh avatar
    7 posts
    Member since:
    Jul 2011

    Posted 21 Sep 2011 Link to this post

    Hi,
    I have an issue with busy indicator & textbox focus. I have tried the fix from http://www.telerik.com/help/silverlight/radbusyindicator-how-to-restore-the-focus.html. This throws an error while running the application. Please help..
    Error is:
    System.Windows.Markup.XamlParseException occurred
      LineNumber=38
      LinePosition=193
      Message=Set property 'Controls.Helper.EnsureFocus' threw an exception. [Line: 38 Position: 193]
      StackTrace:
           at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
           at Iatric.SAM.Shell.Login.InitializeComponent()
           at Iatric.SAM.Shell.Login..ctor()
      InnerException: System.ArgumentException
           Message=Object of type 'System.Windows.Data.Binding' cannot be converted to type 'System.Boolean'.
           StackTrace:
                at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
                at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
                at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, 


    CultureInfo culture, Signature sig)
                at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] 


    parameters, CultureInfo culture, Boolean skipVisibilityChecks)
                at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] 


    parameters, CultureInfo culture)
                at MS.Internal.XamlMemberInfo.SetValue(Object target, Object value)
                at MS.Internal.XamlManagedRuntimeRPInvokes.SetValue(XamlTypeToken inType, XamlQualifiedObject& inObj, 


    XamlPropertyToken inProperty, XamlQualifiedObject& inValue)
           InnerException: 


    My Helper Class:
    Public Class Helper
            Private Shared Sub OnEnsureFocusChanged(ByVal d As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
                If Not CBool(e.NewValue) Then
                    TryCast(d, Control).Focus()
                End If
            End Sub


            Public Shared Function GetEnsureFocus(ByVal obj As DependencyObject) As Boolean
                Return CBool(obj.GetValue(EnsureFocusProperty))
            End Function


            Public Shared Sub SetEnsureFocus(ByVal obj As DependencyObject, ByVal value As Boolean)
                obj.SetValue(EnsureFocusProperty, value)
            End Sub


            Public Shared ReadOnly EnsureFocusProperty As DependencyProperty = DependencyProperty.RegisterAttached("EnsureFocus", GetType(Boolean), GetType(Helper), New PropertyMetadata(Nothing, AddressOf OnEnsureFocusChanged))
        End Class
  2. Ivo
    Admin
    Ivo avatar
    390 posts

    Posted 26 Sep 2011 Link to this post

    Hi Hareesh,

    I would suggest you when creating the new PropertyMetadata for the EnsureFocus DependencyProperty to use the constructor with only one parameter, instead of two. This should solve your issue.
    Public Shared ReadOnly EnsureFocusProperty As DependencyProperty = DependencyProperty.RegisterAttached("EnsureFocus", GetType(Boolean), GetType(Helper), New PropertyMetadata(AddressOf OnEnsureFocusChanged)) 

    Regards,
    Ivo
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Hareesh
    Hareesh avatar
    7 posts
    Member since:
    Jul 2011

    Posted 28 Sep 2011 Link to this post

    Thank you Ivo!!
    This solved my focus issue!!

    Regards,
    Hareesh
Back to Top