C
C#8mo ago
ChaChaCha

Make every textblock in an itemscontrol with an OCollection<string> as the source have a click event

I have an itemscontrl with a OCollection as the source which means it can be updated i have a textblock to display each string in the datatemplaet how can i have every textblock even after updating the list have a click remove event?
1 Reply
ChaChaCha
ChaChaCha8mo ago
what sort of code can i share here
c#


<Style TargetType="{x:Type local:CCJsonInput}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:CCJsonInput}">

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="8*"/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>

<ScrollViewer VerticalScrollBarVisibility="Auto" >
<ItemsControl x:Name="ui_ItemsControl" Grid.Row="0" ItemsSource="{Binding CustomList, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<!--<TextBlock x:Name="ItemInList" Text="{Binding}" FontSize="14" FontWeight="Light" Foreground="#FAF0E6" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5,0,0,0"/>-->
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</ScrollViewer>

<Grid Grid.Row="1">
<local:CustomInputBox x:Name="ui_CustomInputBox" Placeholder="{Binding Placeholder, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>

</Grid>

</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
c#


<Style TargetType="{x:Type local:CCJsonInput}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:CCJsonInput}">

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="8*"/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>

<ScrollViewer VerticalScrollBarVisibility="Auto" >
<ItemsControl x:Name="ui_ItemsControl" Grid.Row="0" ItemsSource="{Binding CustomList, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<!--<TextBlock x:Name="ItemInList" Text="{Binding}" FontSize="14" FontWeight="Light" Foreground="#FAF0E6" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5,0,0,0"/>-->
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</ScrollViewer>

<Grid Grid.Row="1">
<local:CustomInputBox x:Name="ui_CustomInputBox" Placeholder="{Binding Placeholder, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>

</Grid>

</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
thats my cc containing the itemscontrol