Reputation: 7293
i am trying to make a usercontrol that will emulate a regular textbox, but has tags. Something along the lines of this:
but i am having trouble...I tried to do this:
<TextBox>
<Border/>
</TextBox>
but that will not work. How would i do this, without using a richTextBox?
Thanks
Upvotes: 1
Views: 140
Reputation: 856
TextBox is not a container, and therefore hasn't children. Perhaps try wrapping the TextBox in a container object?
Some example code to get you started:
<Border Grid.Row="0" BorderBrush="#FF808080" Background="#FFFFFFFF" >
<DockPanel>
<ItemsControl DockPanel.Dock="Left" ItemsSource="{Binding Tags}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="#FF000000" BorderThickness="1" Margin="3">
<DockPanel>
<Button DockPanel.Dock="Right" Content="X" />
<TextBlock Text="{Binding}" Margin="3" />
</DockPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<TextBox BorderThickness="0" Text="{Binding Text}" VerticalContentAlignment="Center" />
</DockPanel>
</Border>
Restyle and rebind however best fits into your solution.
Upvotes: 1