What I’m looking to do is make a polygon visible if the textbox in the stackedpanel next to it has focus. Basically, it’ll be an indicator to which textbox has focus. This is going to be applied to multiple textboxes so I’d like to make it generic, using a style.
<StackPanel Visibility="{Binding showOpCode}" Margin="0,2" Orientation="Horizontal" >
<TextBlock Width="212" VerticalAlignment="Center">Operation Code:</TextBlock>
<Polygon Width="29" Points="14,8 14,21 28,14.5" Fill="Gray" Stroke="DarkGray"/>
<TextBox HorizontalContentAlignment="Right"
Name="txtOpCode" VerticalAlignment="Bottom" Width="122" Text="0"
Style="{StaticResource normalTextBoxStyle}" />
</StackPanel>
You would be better off building a custom TextBox style that includes the Polygon. You can get the default Styles from here.
Just take the default Style for TextBox and related resources, then add your polygon to the left.
Something like:
Where the xmlns
themeis defined asxmlns:theme="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero". You’d need to add a ref to PresentationFramework.Aero.dll, or change it from a ListBoxChrome to a Border.