Non shareable resources

86 views
Skip to first unread message

Paul Stovell

unread,
Nov 29, 2008, 1:04:27 PM11/29/08
to wpf-di...@googlegroups.com
Hi all,

I was positive that you used to be able to mark an entry in a Resources dictionary as being "non shareable". Something like this:

<Window.Resources>
    <Blah NonShareable="True" x:Key="Foo" />
</Window.Resources>

I don't remember the precise name of the attribute, and I'm having a hard time looking it up.

My goal is that when accessing the resource from a style's setter, it should create a new instance each time, to avoid the dreaded: "Specified element is already the logical child of another element. Disconnect it first."

--
Paul Stovell
http://www.paulstovell.net

Josh Wagoner

unread,
Nov 29, 2008, 1:11:24 PM11/29/08
to wpf-di...@googlegroups.com
I’m pretty sure it’s x:Shared=”False”.

corrado...@gmail.com

unread,
Nov 29, 2008, 1:13:39 PM11/29/08
to WPF Disciples
Confirm: x:Shared="False"


On Nov 29, 7:11 pm, Josh Wagoner <wagoner.j...@gmail.com> wrote:
> I¹m pretty sure it¹s x:Shared=²False².
>
> On 11/29/08 10:04 AM, "Paul Stovell" <stov...@gmail.com> wrote:
>
>
>
> > Hi all,
>
> > I was positive that you used to be able to mark an entry in a Resources
> > dictionary as being "non shareable". Something like this:
>
> > <Window.Resources>
> >     <Blah NonShareable="True" x:Key="Foo" />
> > </Window.Resources>
>
> > I don't remember the precise name of the attribute, and I'm having a hard time
> > looking it up.
>
> > My goal is that when accessing the resource from a style's setter, it should
> > create a new instance each time, to avoid the dreaded: "Specified element is
> > already the logical child of another element. Disconnect it first."- Hide quoted text -
>
> - Show quoted text -

Paul Stovell

unread,
Nov 29, 2008, 1:16:19 PM11/29/08
to wpf-di...@googlegroups.com
Thank you Josh and Corrado, this has finally solved a problem I've been battling with for the last 6 hours :)

For some reason the extended x: attributes don't show in the XAML intellisense nor resharper, and googling "wpf resourcedictionary share" doesn't help. Trust the disciples to come to my rescue :-)

Laurent Bugnion, GalaSoft [MVP]

unread,
Nov 29, 2008, 1:42:19 PM11/29/08
to wpf-di...@googlegroups.com

Paul,

 

I wanted to check if it was due to Resharper, but even in the “standard” Intellisense, the x:Shared attribute doesn’t show up. Is that a bug? I’ll ask Rob Relyea.

 

Cheers,

Laurent

No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.176 / Virus Database: 270.9.11/1819 - Release Date: 11/29/2008 10:37 AM

Karl Shifflett

unread,
Nov 29, 2008, 2:47:56 PM11/29/08
to wpf-di...@googlegroups.com
I'll look into this on Monday.

________________________________

Paul,

Cheers,

Laurent


Confirm: x:Shared="False"


--
Paul Stovell
http://www.paulstovell.net <http://www.paulstovell.net/>

winmail.dat

Josh Smith

unread,
Nov 29, 2008, 4:50:57 PM11/29/08
to wpf-di...@googlegroups.com
One of my presentations about WPF includes showing how to use x:Shared="False" and it inevitable comes as a surprise, even to seasoned WPF devs.  The Intellisense in Cider should show it.  No reason not to.

Josh

Jeremiah Morrill

unread,
Nov 29, 2008, 6:39:30 PM11/29/08
to wpf-di...@googlegroups.com
I wonder if it's like Dispatcher.VerifyAccess()/CheckAccess() having the [EditorBrowsable(EditorBrowsableState.Never)] attribute set.  Thats a Scooby-Doo caliber mystery in itself.

-Jer

Marlon Grech

unread,
Nov 30, 2008, 2:55:39 AM11/30/08
to wpf-di...@googlegroups.com
the x:Shared never worked in my intellisense and I never had resharper on this machine....
--
Regards
Marlon
WPF Blog - http://marlongrech.wordpress.com/

Reply all
Reply to author
Forward
0 new messages