I have a resource in a ResourceDictionary:
<Viewbox x:Key="Icons.Profile">
<Canvas Width="76" Height="76" Clip="F1 M 0,0L 76,0L 76,76L 0,76L 0,0">
<Path Width="40.7907" Height="33.55" Canvas.Left="16.2093" Canvas.Top="22.2" Stretch="Fill" Fill="#FFFFFFFF" Data="F1 M ... "/>
</Canvas>
</Viewbox>
If I add two Buttons/Content Controls that reference the StaticResource only the one rendered last seems to render the "Icon"
<Button Content="{StaticResource Icons.Profile}" />
Does anyone know why and how I can get around this? In Visual Studio and Blend the Content is being rendered for all controls.
This is because a element can only have 1 logical parent, however you can set your resource to x:Shared="false"
and this will create/render a new element for each use.
Example:
<Viewbox x:Key="Icons.Profile" x:Shared="false">
<Canvas Width="76" Height="76" Clip="F1 M 0,0L 76,0L 76,76L 0,76L 0,0">
<Path Width="40.7907" Height="33.55" Canvas.Left="16.2093" Canvas.Top="22.2" Stretch="Fill" Fill="#FFFFFFFF" Data="F1 M ... "/>
</Canvas>
</Viewbox>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With