Hallo,
ich möchte einem Dockpanel ein Background Image hinzufügen. Das Image soll aus einem XAML Path erzeugt werden, also eine Vektorgrafik.
Als Background sind diverse Brushes möglich. Leider finde ich nicht heraus, welchen Brush in welcher verschachtelten Ebene ich verwenden muss, um irgendwie die Daten des XAML Paths eingeben zu können.
Jemand eine Idee wie man den XAML Path in solch einen Brush integriert bekommt?
<Path x:Name="itemImgPath"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="m 23.635,37.411 c 0.76,-0.238 1.565,-0.392 2.314,-0.492 L 25.23,35.987 C 17.946,34.472 12.456,28.006 12.456,20.279 c 0,-8.845 7.198,-16.043 16.045,-16.043 8.847,0 16.042,7.197 16.042,16.043 0,1.92 -0.356,3.755 -0.978,5.463 0.535,0.666 1.072,1.377 1.564,2.095 1.05,-2.306 1.649,-4.859 1.649,-7.558 C 46.779,10.186 38.595,2 28.501,2 c -10.096,0 -18.28,8.186 -18.28,18.279 0,8.133 5.316,15.019 12.66,17.392 0.242,-0.089 0.489,-0.177 0.754,-0.26 z m 26.517,0.3 c -0.179,-0.242 -0.447,-0.403 -0.745,-0.445 -0.302,-0.038 -0.602,0.038 -0.84,0.223 l -0.721,0.557 c -0.526,-1.676 -1.584,-4.861 -2.721,-7.247 -1.576,-3.304 -5.938,-7.7 -5.938,-7.7 0,0 -0.943,-1.223 -2.131,-1.223 -0.366,0 -0.754,0.116 -1.145,0.416 -1.658,1.279 -0.058,3.361 -0.05,3.371 -0.006,-0.008 -0.947,-1.223 -2.131,-1.223 -0.366,0 -0.754,0.115 -1.146,0.417 -1.657,1.277 -0.057,3.359 -0.049,3.37 -0.006,-0.008 -0.978,-1.263 -2.137,-1.263 -0.333,0 -0.682,0.103 -1.028,0.37 -1.551,1.198 -0.16,3.455 -0.16,3.455 l -5.102,-6.612 c 0,0 -1.531,-1.986 -3.123,-1.986 -0.383,0 -0.769,0.114 -1.138,0.399 -1.903,1.47 0.449,4.526 0.449,4.526 L 28.9,38.264 c 0,0 -0.093,-0.003 -0.258,-0.003 -0.718,0 -2.806,0.052 -4.559,0.599 -3.8,1.193 -4.464,2.791 -3.778,4.467 0.153,0.377 0.669,0.518 1.397,0.518 2.112,0 6.021,-1.176 8.163,-1.176 0.148,0 0.287,0.006 0.418,0.018 2.618,0.24 5.503,2.427 6.889,3.607 l -0.404,0.312 c -0.48,0.371 -0.577,1.057 -0.218,1.546 l 5.58,7.607 1.803,-1.322 -4.935,-6.729 10.029,-7.75 4.905,6.683 1.803,-1.324 -5.583,-7.606 z"
Fill="Black" />
Hallo Jochen,
die VisualBrush-Klasse dürfte das richtige für dich sein.
Beispiel:
<VisualBrush TileMode="Tile"
Viewport="0 0 15 15"
ViewportUnits="Absolute"
Viewbox="0 0 15 15"
ViewboxUnits="Absolute">
<VisualBrush.Visual>
<Grid>
<Path Data="M 0 15 L 15 0" Stroke="#88FFFFFF"/>
<Path Data="M 0 0 L 15 15" Stroke="#88FFFFFF"/>
</Grid>
</VisualBrush.Visual>
</VisualBrush>
Hi,
spiel damit mal rum
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication1"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.Resources>
<Canvas Width="48" Height="48" Clip="F1 M 0,0L 48,0L 48,48L 0,48L 0,0" UseLayoutRounding="False" x:Key="itemImgPath">
<Path x:Name="itemImgPath"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="m 23.635,37.411 c 0.76,-0.238 1.565,-0.392 2.314,-0.492 L 25.23,35.987 C 17.946,34.472 12.456,28.006 12.456,20.279 c 0,-8.845 7.198,-16.043 16.045,-16.043 8.847,0 16.042,7.197 16.042,16.043 0,1.92 -0.356,3.755 -0.978,5.463 0.535,0.666 1.072,1.377 1.564,2.095 1.05,-2.306 1.649,-4.859 1.649,-7.558 C 46.779,10.186 38.595,2 28.501,2 c -10.096,0 -18.28,8.186 -18.28,18.279 0,8.133 5.316,15.019 12.66,17.392 0.242,-0.089 0.489,-0.177 0.754,-0.26 z m 26.517,0.3 c -0.179,-0.242 -0.447,-0.403 -0.745,-0.445 -0.302,-0.038 -0.602,0.038 -0.84,0.223 l -0.721,0.557 c -0.526,-1.676 -1.584,-4.861 -2.721,-7.247 -1.576,-3.304 -5.938,-7.7 -5.938,-7.7 0,0 -0.943,-1.223 -2.131,-1.223 -0.366,0 -0.754,0.116 -1.145,0.416 -1.658,1.279 -0.058,3.361 -0.05,3.371 -0.006,-0.008 -0.947,-1.223 -2.131,-1.223 -0.366,0 -0.754,0.115 -1.146,0.417 -1.657,1.277 -0.057,3.359 -0.049,3.37 -0.006,-0.008 -0.978,-1.263 -2.137,-1.263 -0.333,0 -0.682,0.103 -1.028,0.37 -1.551,1.198 -0.16,3.455 -0.16,3.455 l -5.102,-6.612 c 0,0 -1.531,-1.986 -3.123,-1.986 -0.383,0 -0.769,0.114 -1.138,0.399 -1.903,1.47 0.449,4.526 0.449,4.526 L 28.9,38.264 c 0,0 -0.093,-0.003 -0.258,-0.003 -0.718,0 -2.806,0.052 -4.559,0.599 -3.8,1.193 -4.464,2.791 -3.778,4.467 0.153,0.377 0.669,0.518 1.397,0.518 2.112,0 6.021,-1.176 8.163,-1.176 0.148,0 0.287,0.006 0.418,0.018 2.618,0.24 5.503,2.427 6.889,3.607 l -0.404,0.312 c -0.48,0.371 -0.577,1.057 -0.218,1.546 l 5.58,7.607 1.803,-1.322 -4.935,-6.729 10.029,-7.75 4.905,6.683 1.803,-1.324 -5.583,-7.606 z"
Fill="Black" />
</Canvas>
</Grid.Resources>
<Border Background="Moccasin" HorizontalAlignment="Center" Width="400" Height="282">
<Border.OpacityMask>
<VisualBrush Visual="{StaticResource itemImgPath}" Stretch="Fill" />
</Border.OpacityMask>
</Border>
</Grid>
</Window>
hübsch! 👍
spiel damit mal rum Jo, zB das Canvas kann man weglassen.
Der frühe Apfel fängt den Wurm.