I made a custom made style for a textbox using PATH. The box looks exactly how i wanted it but when i write any text in it, nothing seems to appear. It would seem that something inside my style is either blocking it or i need to add something for the content to appear. But im not sure what exactly, does anyone have any insight on what i could do to make the text appear inside the custom made box?
<Style x:Key="AppearingTextbox" TargetType="{x:Type TextBox}">
<Setter Property="Cursor" Value="Arrow"/>
<Setter Property="Foreground" Value="#3E82C4"/>
<Setter Property="Background" Value="#0F1C2B"/>
<Setter Property="Opacity" Value="0"/>
<Setter Property="IsReadOnly" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<StackPanel>
<Path Data="M0 0 30 0 50 -10 70 0 100 0 100 30 0 30z" Fill="#0F1C2B"/>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=Ikona, Path=IsMouseOver}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard >
<Storyboard TargetProperty="Opacity" Duration="00:00:00.3" AutoReverse="False">
<DoubleAnimation From="0" To="1" Duration="00:00:00.3"/>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard >
<Storyboard TargetProperty="Opacity" Duration="00:00:00.3" AutoReverse="False">
<DoubleAnimation From="1" To="0" Duration="00:00:00.3"/>
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
That is applied to this TextBox:
<TextBox Style="{DynamicResource AppearingTextbox}" Height="30" Width="100" FontSize="10" Margin="0,480,0,0">
Some text
</TextBox>
Thanks a bunch people i managed to get it working. I couldnt put it inside of a Border tag because border tag accepts only 1 child element. Instead I used Grid. Grid is also good because in documentation I read somewhere that it allows stacking elements on top of each other. This is what I did for anyone that stumbles on this in the future.
In the <ControlTemplate>
tag I did the following:
<ControlTemplate TargetType="{x:Type TextBox}">
<Grid>
<Path Data="M0 0 30 0 50 -10 70 0 100 0 100 30 0 30z" Fill="#0F1C2B"/>
<ScrollViewer Margin="0" x:Name="PART_ContentHost" />
</Grid>
</ControlTemplate>
Which immediately made the text appear inside the box I made. A little styling made the text right where I wanted it but that's about it.
Thanks a lot people and consider this solved :)