Enrique posted on January 13, 2010 13:07

I’m going to quickly post the solution to this issue since its late ..or too early 5:41 a.m EST  basically when working with WPF using  CAL-PRISM- or whatever you want to call the Composite Application Guidance for WPF and Silverlight and you want to show a popup window you may want to use the WindowRegionAdapter from the WPF Contrib project   the problem is when you close the windows you may have the exception {"Cannot change ObservableCollection during a CollectionChanged event."}

 

private void window_Closed(object sender, EventArgs e)
{
Window window = sender as Window;
IRegion region = _regionWeakReference.Target as IRegion;
if (window != null && region != null)
if (region.Views.Contains(window.Content))
region.Remove(window.Content);//exception
                                             //Cannot change ObservableCollection 
                                             //during a CollectionChanged event."} 
}

 

 

 

I have made some changes to WindowRegionAdapter.cs in order to fix it and seems to be working, here are the changes:

add:

using System.Threading;
replace the  window_Closed  code for the code below:
 
class CloseWindwowCallbackParameter
{
    public IRegion theRegion { get; set; }
    public Window windowToClose { get; set; }
}
private void closeWindowinThread(object parameters)
{
    CloseWindwowCallbackParameter arguments = parameters as CloseWindwowCallbackParameter;
    IRegion region = arguments.theRegion;
    Window window = arguments.windowToClose;
    window.Dispatcher.Invoke(
                       System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
  {
      region.Remove(window.Content);
  }));
 
}
 
private void window_Closed(object sender, EventArgs e)
{
 
    Window window = sender as Window;
    IRegion region = _regionWeakReference.Target as IRegion;
    if (window != null && region != null)
        if (region.Views.Contains(window.Content))
        {
            WaitCallback callback = new WaitCallback(closeWindowinThread);
            ThreadPool.QueueUserWorkItem(callback, new CloseWindwowCallbackParameter 
                                                 {theRegion = region, windowToClose = window });
        }
}


Posted in: WPF  Tags: , ,
Enrique posted on October 14, 2009 22:25

If you downloaded the RibbonControlsLibrary.dll  and having a hard time, for example I was having this error:

Undefined CLR namespace. The ‘clr-namespace’ URI refers to a namespace ‘Microsoft.Windows.Controls.Ribbon’ that is not included in the assembly.

you should read the comments found at the bottom of this post:

http://teusje.wordpress.com/2009/08/12/wpf-office-ribbon-control/

basically the dll is being blocked by the OS and visual studio is unable to load and use it, the solution is right click on the file and unblock it; after that  you may need to recreate(add\delete) the reference or\and open/close the solution again.

image

image


Posted in: WPF  Tags: , ,

If you are having the “'This TextNavigator' has no scoping text element.” exception working with the richtextbox control in WPF, probably you are manipulating the xaml "manually” and, at least in my case,  because an empty BlockUIContainer block.


Posted in: WPF  Tags: , ,

Calendar

«  March 2010  »
MoTuWeThFrSaSu
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234
View posts in large calendar

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010 BizTalkAnd .Net