Skip to main content

Microsoft Silverlight

Answered Question Not able to add Datagrid in Beta 2RSS Feed

(0)

Dhawal Shah
Dhawal Shah

Member

Member

14 points

9 Posts

Not able to add Datagrid in Beta 2

I had an existing project which I converted to Beta 2. I was using a datagrid in it but was getting a lot of erorrs. So I removed the datagrid and tried adding a new one. I got the following error:

"The operation could not be completed. Invalid FORMATETC structure" 

yifung
yifung

Contributor

Contributor

3313 points

540 Posts

Microsoft

Re: Not able to add Datagrid in Beta 2

If you did any templating of the DataGrid, you'll need to redo it because the template changed a good amount.  If not, I would compare your project file with one from a new SL application for Beta2 and see what's different between the two.  Also compare the Pages

Yifung Lin [MSFT]

Dhawal Shah
Dhawal Shah

Member

Member

14 points

9 Posts

Re: Re: Not able to add Datagrid in Beta 2

Okay. As of now I have commented the code. But when I try to add a new Datagrid control from the toolbox I get the above mentioned FORMATTEC error. And if I try to add the datagrid manually by typing in the XAML then I get the following error on compiling:

Error 1 Derived method 'OnApplyTemplate' in type 'System.Windows.Controls.DataGrid' from assembly 'System.Windows.Controls.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' cannot reduce access. \

deslo
deslo

Member

Member

31 points

44 Posts

Re: Re: Not able to add Datagrid in Beta 2

I'm having the same problem.

lee_sl
lee_sl

Contributor

Contributor

2990 points

584 Posts

Re: Re: Not able to add Datagrid in Beta 2

Make the 'OnApplyTemplate'  method public

----------------------------------------------
Available for consulting in Dallas, TX
http://leeontech.wordpress.com/

cyberhuey
cyberhuey

Member

Member

18 points

13 Posts

Re: Re: Not able to add Datagrid in Beta 2

lee_sl:

Make the 'OnApplyTemplate'  method public

Ok I'll bite. Where is this done. Also is the xmlns:my="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"  still valid?

 

vsi
vsi

Member

Member

14 points

3 Posts

Answered Question

Re: Not able to add Datagrid in Beta 2

i've fixed this issue by removing and readding the System.* references in the project.

 

Dhawal Shah
Dhawal Shah

Member

Member

14 points

9 Posts

Re: Re: Not able to add Datagrid in Beta 2

Thanks vsi. Your fix worked.

cyberhuey
cyberhuey

Member

Member

18 points

13 Posts

Re: Re: Not able to add Datagrid in Beta 2

I finally got this working by opening a new project and adding a datagrid - and then copying everything over to the new project. There was probably some odd reference in there somewhere - but regardless making a new project fixed it.

K2P2
K2P2

Participant

Participant

1026 points

336 Posts

Re: Re: Not able to add Datagrid in Beta 2

I am having this problem with my whole solution.

In any project that I try to drop a button from the toolbox to any xaml I get this error (I tried 4 out of 10 projects).

 I can hand code the button in xaml ok.  But I can't drag and drop from the toolbox.

 

sladapter
sladapter

All-Star

All-Star

17439 points

3,172 Posts

Re: Re: Not able to add Datagrid in Beta 2

If you just convert your beta1 project to beta2. You need to remove System.Windows.dll, System.Windows.Controls.dll from References. Then add System.Windows.dll, System.Windows.Controls.Data.dll, System.Windows.Controls.Extended.dll to the References. Before you hit compile, exit VS (otherwise, you might get a lot of error which does not make any sense). Then re-open VS to compile your project. Now you should be able to get some meaningful compiling errors which you have to fix by hand. 

You also need to check your Xaml files. Because a lot of breaking changes in beta2, some property name changed you need to fix them by hand. The compiler should indicate which line is invalid.

 

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

K2P2
K2P2

Participant

Participant

1026 points

336 Posts

Re: Re: Not able to add Datagrid in Beta 2

I never used Beta 1.  I started with Beta 2.

K2P2
K2P2

Participant

Participant

1026 points

336 Posts

Re: Re: Not able to add Datagrid in Beta 2

Opps.  Maybe my memory is bad.  I have been using Beta 2 for quite a while without any problems.  This just started.  Although I'll try your procedure and see what happens (everything compiles fine and executes).

sladapter
sladapter

All-Star

All-Star

17439 points

3,172 Posts

Re: Re: Not able to add Datagrid in Beta 2

I thought you had the same problem as the original poster. If you have been running beta2 for a while, then my post does not apply. Where do you want to drop the control? You can only drop it to the Xaml area, not the designer area.

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

K2P2
K2P2

Participant

Participant

1026 points

336 Posts

Re: Re: Not able to add Datagrid in Beta 2

The following Button works fine.  If you try to drag a button from the Toolbox above or below it you get the error.  (And this happens in any xaml in any project in my solution.  It happens within a Canvas or StackPanel or any general xaml anywhere in my Solution that I have tried so far -- 5 or 6 different xaml files so far.)

 I usually hand code my xaml so it might have been a while since I dragged and dropped something.  So It might be hard to tell when this started.

Thanks

<
UserControl x:Class="SilverLightDemo.UseThis"
xmlns=http://schemas.microsoft.com/client/2007
xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
Width="700" Height="700">
<Canvas x:Name="LayoutRoot" Background="White">
<TextBox x:Name="TextBox1" Canvas.Left="10" Canvas.Top="10"
Text="Nothing" Width="100" Height="30" />

 

<Button Width="100" Height="20" Margin="200,50,0,0" ></Button>

</Canvas>

</UserControl>

sladapter
sladapter

All-Star

All-Star

17439 points

3,172 Posts

Re: Re: Not able to add Datagrid in Beta 2

I tried your Xaml. It works fine. I can Drag and Drop any control in it. Have you tried to add a UserControl or even start a new Silverlight project and see if you still have the same problem? 

 

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

K2P2
K2P2

Participant

Participant

1026 points

336 Posts

Re: Re: Not able to add Datagrid in Beta 2

This isn't a very high priority to me because I can do everything by hand.

To test your idea I just added a new Silverlight Application project to my solution:

1)  Right click "Solution \ Add \ New Project"
2)  Select "Silverlight Application" and press OK.
3)  Uncheck "Add Test page..." and press OK.
4)  Drag a "Button" from the toolbox into the "Grid" and get the error.

I also created a new solution:

A)  Open VS 2008 standard
B)  Select "File \ New \ Project" and "ASP.NET Web Application"
C)  Follow steps 1 through 4 above and get the error.

Then I created a new solution:

A)  Open VS 2008 standard
B)  Select "File \ New \ Project" and "Silverlight Application"
C)  Select "Dynamically generate an HTML test page..."
D)  Drag a "Button" from the toolbox into the "Grid" and get the error.

This leads me to think that something needs to be re-installed.

jreski
jreski

Member

Member

2 points

1 Posts

Re: Re: Not able to add Datagrid in Beta 2

Hi,

I have the same problem. I can't drag and drop from the toolbox to the XAML code.

MessageBox "The operation could be completed" 

Has anyone a solution?

Best regards

Jochen

 

cyberhuey
cyberhuey

Member

Member

18 points

13 Posts

Re: Re: Re: Not able to add Datagrid in Beta 2

I tend to do all of my GUI work in Expressions Blend and only code in Visual Studio. I cannot get the same control of looks and ease of use, not to mention the oh so long time it takes the cider to interprit the XAML.

yifung
yifung

Contributor

Contributor

3313 points

540 Posts

Microsoft

Re: Re: Not able to add Datagrid in Beta 2

One thing you can try is right clicking the empty space inside the toolbox and select Reset toolbox

Yifung Lin [MSFT]

earthtechconcepts
earthtec...

Member

Member

12 points

6 Posts

Re: Re: Not able to add Datagrid in Beta 2

Hi - i am have been spending a significant amount of time just trying to get the environment set up..  and having this exact same problem.

i have a new laptop and installed the new wpi install, have visual studio express c#, visual Web, ms sql  

still banging my head against the wall - i am having this same problem and i tried everything here - deleted and added back the references, reset the toolbox, etc.

is there anyone that can help me as i am at a dead end here.


www.earthtechconcepts.com
Earth Tech Concepts, Inc.

yifung
yifung

Contributor

Contributor

3313 points

540 Posts

Microsoft

Re: Re: Not able to add Datagrid in Beta 2

For clearing the toolbox give this a try:

Close all instances of Microsoft Visual Studio.2.       Delete all cached toolbox items by removing all files beginning with "toolbox" from %LocalAppData%\Microsoft\VisualStudio\9.0.
  • On Microsoft Windows XP, %LocalAppData% is Documents and Settings\UserName\Local Settings\Application Data.
  • On Microsoft Windows Vista, %LocalAppData% is Users\UserName\AppData\Local.

 

Btw, I recommend going to the RTM version of SL if you haven't, and there's an even newer version of the DataGrid:

http://silverlight.net/forums/t/59990.aspx

Yifung Lin [MSFT]
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities