Ouch. Looks like a bug to me.
I recently used a custom control as the content of the header without issues, so if you need to do more than basic UI in the header that could be an option. Carl. Carl Scarlett Senior .NET/WPF Developer, UX Designer | Genesis IT & Change Management | Bankwest A: Level 5, 199 Hay Street | Perth | Western Australia | 6004 P: (08) 9449 8451 M: 0408 913 870 E: [email protected] Description: test From: [email protected] [mailto:[email protected]] On Behalf Of Steven Nagy <[email protected]> Sent: Monday, 12 December 2011 9:21 AM To: "[email protected]" <[email protected]> Subject: Expander Header via style throws error Hiyas, Really simple to recreate this issue, just paste in this code to a new WPF project: <Grid> <Grid.RowDefinitions> <RowDefinition Height="*" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Grid.Resources> <Style x:Key="ExpanderStyle" TargetType="Expander"> <Setter Property="Header"> <Setter.Value> <Grid> <TextBlock Text="Foo" /> </Grid> </Setter.Value> </Setter> </Style> </Grid.Resources> <Expander Style="{StaticResource ExpanderStyle}" /> <Expander Style="{StaticResource ExpanderStyle}" Grid.Row="1" /> </Grid> Essentially, 2 expanders using the same style to set the header. Throws this exception: "'Set property 'System.Windows.FrameworkElement.Style' threw an exception.' Line number '23' and line position '10'" Inner exception: "Specified element is already the logical child of another element. Disconnect it first." However if you sacrifice the complex header content for something simple like this, it works fine: <Setter Property="Header" Value="Foo" /> Any ideas why this is the case? Using style inheritance from the same base style causes same issue. However if I blanket copy paste the style with a new name and point the expander to that, then it also works fine. So it's not the header content that's the problem specifically. I'm guessing some sort of virtualisation similar to what the tab control does with tab pages under binding scenarios; it is using the same actual Grid control and applying it to both headers, thus the inner exception above. No idea how to fix it though (other than copying pasting styles which I really don't want to do). Cheers, Steve ______________________________________________________________________ This email has been scanned by the Symantec Email Security.cloud service. For more information please visit http://www.symanteccloud.com ______________________________________________________________________ _______________________________________________ ozwpf mailing list [email protected] http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf ________________________________________________________________________ _______ This email has been scanned by the Bankwest Email Security System. ________________________________________________________________________ _______ _______________________________________________________________________________ Unencrypted electronic mail is not secure and may not be authentic. If you have any doubts as to the contents please telephone to confirm. This electronic transmission including any attachments is intended only for those to whom it is addressed. It may contain copyright material or information that is confidential, privileged or exempt from disclosure by law. Any claim to privilege is not waived or lost by reason of mistaken transmission of this information. If you are not the intended recipient you must not distribute or copy this transmission and should please notify the sender. Your costs for doing this will be reimbursed by the sender. We do not accept liability in connection with computer virus, data corruption, delay, interruption, unauthorised access or unauthorised amendment. _______________________________________________________________________________ ______________________________________________________________________ This email has been scanned by the Symantec Email Security.cloud service. For more information please visit http://www.symanteccloud.com ______________________________________________________________________
<<inline: image001.png>>
_______________________________________________ ozwpf mailing list [email protected] http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf
