This is a migrated thread and some comments may be shown as answers.

Focus Restoring in Busy Indicator

2 Answers 107 Views
BusyIndicator
This is a migrated thread and some comments may be shown as answers.
Hareesh
Top achievements
Rank 1
Hareesh asked on 21 Sep 2011, 07:28 AM
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 Answers, 1 is accepted

Sort by
0
Ivo
Telerik team
answered on 26 Sep 2011, 07:48 AM
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 >>

0
Hareesh
Top achievements
Rank 1
answered on 28 Sep 2011, 06:25 AM
Thank you Ivo!!
This solved my focus issue!!

Regards,
Hareesh
Tags
BusyIndicator
Asked by
Hareesh
Top achievements
Rank 1
Answers by
Ivo
Telerik team
Hareesh
Top achievements
Rank 1
Share this question
or