locked
Help : ComponentProperty - Is Always Read Only RRS feed

  • Question

  •  

    Hi:

    The XAML for the Part's connection point looks like this:

     

    <ComponentProperty Name="NamePendingAddition" IsReadOnly="False"/>

     

    In the code for the initialization of my Part I set a property of my Part class to the ConnectionPoint's Value property:

     

    this.NamePendingAddition.Value = this.MyNamePendingAddition;

     

    I do a simple Binding in the PartView's XAML like this:

    <TextBlock Name="idPendingName" Text="{Binding Part.NamePendingAddition.Value}" />

     

     

    I always get an exception at runtime complaining that the ConnectionPoint is READ ONLY !!

     

    System.InvalidOperationException was unhandled
      Message="A TwoWay or OneWayToSource binding cannot work on the read-only property 'NamePendingAddition' of type 'AcropolisApp4.TestPart'."
      Source="PresentationFramework"
      StackTrace:
           at MS.Internal.Data.PropertyPathWorker.CheckReadOnly(Object item, Object info)
           at MS.Internal.Data.PropertyPathWorker.ReplaceItem(Int32 k, Object newO, Object parent)
           at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)
           at MS.Internal.Data.ClrBindingWorker.AttachDataItem()
           at System.Windows.Data.BindingExpression.Activate(Object item)
           at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt)
           at System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance)
           at MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance)
           at MS.Internal.Data.DataBindEngine.Run(Object arg)
           at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
           at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
           at System.Windows.Threading.DispatcherOperation.InvokeImpl()
           at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
           at System.Threading.ExecutionContext.runTryCode(Object userData)
           at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
           at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Windows.Threading.DispatcherOperation.Invoke()
           at System.Windows.Threading.Dispatcher.ProcessQueue()
           at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
           at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
           at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
           at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
           at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
           at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
           at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
           at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
           at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
           at System.Windows.Threading.Dispatcher.Run()
           at System.Windows.Application.RunInternal(Window window)
           at System.Windows.Application.Run(Window window)
           at System.Windows.Application.Run()
           at AcropolisApp4.Application.Main() in F:\Users\markb\Documents\AcropolisApp4\AcropolisApp4\obj\Debug\AcropolisApp4.Application.g2.cs:line 38
           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException:

     

     

     

     

    Friday, September 7, 2007 12:15 AM

Answers

  • Hi Puffy,

     

    Since I can't see all of your code, I'd suggest taking a look at the Notepad sample we shipped as part of CTP3. The view for the NotepadPart (NotepadPartView.xaml) databinds to the NotepadPart.NotepadText.Value property and two way binding works between the UI and the part's property.  If you still can't figure out why WPF databinding is failing then I'd suggest sending in a small repro sample of what you are trying to do so that we can look at all of the code in it's full context.

     

    Thanks,

     

     

     

    Tuesday, September 25, 2007 7:03 PM