possible bug
I encountered a design time error on the EventSetter line below. The thing is, Selected is an event for ListViewItem. Also, the handler gets fired nomally. I haven't reported this yet because I'd prefer to get confirmation first.
<Style TargetType="ListViewItem">
<EventSetter Event="Selected" Handler="ListViewItem_Selected"/> </Style>Error 18 Value 'Selected' cannot be assigned to property 'Event'. Invalid event name.
Answers
I have reported this as a bug, if anyone here has seen or can confirm this bug, please add verification if you have the time to spare.
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=335722
All Replies
- Yes this is a bug. Please use the Connect web site to report it - thanks - mark
I have reported this as a bug, if anyone here has seen or can confirm this bug, please add verification if you have the time to spare.
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=335722
- Thanks for reporting the bug - much appreciated - mark
I experiance something similar. The designer in Visual Studio 2008 Professionel Edition says it has a problem loading when I use EventSetters in a specific way. The error message is "Cannot load XAML file that has EventSetters. Try compiling the XAML". The line number does not match the line where my EventSetter is.
When I compile the XAML it works fine and the event fires.
Here is the code that makes the designer fail:
Code Snippet<
Window.Resources>
<ObjectDataProvider x:Key="dataModel" ObjectType="local:DataModel"/> <DataTemplate x:Key="MyTemplate">
<Grid>
<Grid.Resources>
<Style TargetType="{x:Type Button}">
<EventSetter Event="Click" Handler="mouseclick"/> </Style> </Grid.Resources> <Button Width="100" Height="50" Content="{Binding}" /> </Grid> </DataTemplate> </Window.Resources> <ListBox ItemsSource="{Binding Source={StaticResource dataModel}, Path=Persons}" ItemTemplate="{StaticResource MyTemplate}"/>I have Blend 2 trail installed alongside. Earlier I had Blend 2 beta February release. Both of these have the same problem reading this XAML!
- I have a similar problem,
<Window.Resources>
...
<Style x:Key="EditableTextBoxStyle" TargetType="{x:Type TextBox}">
<EventSetter Event="TextChanged" Handler="TextBox_TextChanged"/>
</Style>
...
</Window.Resources>
Rebuild in Blend gives "Cannot load XAML file that has EventSetters. Try compiling the XAML..."
I'm using the June 2008 preview.
The code compiles in Visual Studio 2008
Rainer - This seems to be fixed in Visual Studio 2008 with SP1 installed. The Cider designer handles it fine. Unfortunately Expression Blend is still broken. In Blend 1.0 you would get the error message but it would still allow you to design the control, in Blend 2.0 you can no longer design the control at all unless you comment out the EventSetter. I have posted a followup to an existing thread on the Blend forum offering a demo project to anyone at Microsoft willing to take a look:
http://social.expression.microsoft.com/Forums/en-US/blend/thread/49c7a0af-0c20-4a10-b82b-0cb4dca3eef6
If you are interested in getting this bug fixed in Blend, I suggest participating in that thread. - Steffen if you move your Style from the Grid.Resources to the Window.Resources this should fix the designer problem. Well, I had a similiar error and it worked for me!
Steffen,
Could you please let me know whether you were able to fix this? I am gettting the same error.
Thanks,


