Answer the question
In order to leave comments, you need to log in
How to solve the problem of displaying an image when using RelativeSource TemplatedParent?
Button style
<Style TargetType="Button" x:Key="Style_Navigation_Btn">
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button" >
<Border
x:Name="border"
BorderBrush="#EFEFEF"
BorderThickness ="0 0 0 1"
Background="White"
Cursor="Hand">
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="250"/>
</Grid.ColumnDefinitions>
<Image
x:Name="image"
Width="30"
Height="50"
Source ="{Binding Path=Tag, RelativeSource="{RelativeSource TemplatedParent}}" / >
<TextBlock
x:Name="text"
Foreground="#3094e6"
FontSize="20"
Margin="10 0 0 0"
VerticalAlignment="Center"
Text="{TemplateBinding Content}"
Grid.Column="1" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="Background" Value="#3094e6" />
<Setter TargetName="text" Property="Foreground" Value="white"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Button
Command="{Binding bStorage}"
Tag="C:\Users\akautdinov_ai\Desktop\StorageApp\StorageApp\Images\package.png" Style="{StaticResource Style_Navigation_Btn}"
Content="Склад" />
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question