Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
If want to share Image in ResourceDictionary, there is another way except using x:Shared=”false”.
<Application.Resources>
<BitmapImage x:Key="bitmapImage"
UriSource="pack://application:,,,/Resource/Dock.JPG"/>
<DataTemplate x:Key="dataTemplate" x:Shared="false">
<Border Background="Blue" Margin="10">
<Image Source="{StaticResource bitmapImage}"/>
</Border>
</DataTemplate>
</Application.Resources>
Instead of creating Image as resource, create BitmapImage as resource and use as the Source of Image in DataTemplate.
Comparing it with using x:Shared=”false”, it will create 3 Image control instances but only one BitmapImage control instance.
But if we use x:Shared=”false”, it will create 3 Image control instances and 3 BitmapFrameDecode instance.
Comments
- Anonymous
December 25, 2008
PingBack from http://www.codedstyle.com/xshared-attribute-in-xaml-3/