How to count the no. of times the given character in second TextBox appears in First Textbox and add the index and matched character to ListBox
- Get link
- X
- Other Apps
MainWindow
<Window x:Class="WPFWorldTutorial.Views.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True">
<Grid>
<StackPanel Orientation="Vertical">
<TextBox Text="{Binding Text}" Height="25" Margin="5"/>
<TextBox Text="{Binding CharToMatch}" Height="25" Margin="5"/>
<Button Content="Match" Command="{Binding MatchCharCommand}" Width="100" Margin="5"/>
<ListBox ItemsSource="{Binding MatchedInfo}">
<ListBox.Style>
<Style TargetType="ListBox">
<Setter Property="Visibility" Value="Visible"/>
<Style.Triggers>
<DataTrigger Binding="{Binding MatchedInfo.Count}" Value="0">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ListBox.Style>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Charecter}" Margin="5"/>
<TextBlock Text="->" Margin="5"/>
<TextBlock Text="{Binding Position}" Margin="5"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</Grid>
</Window>
- Get link
- X
- Other Apps
Comments
Post a Comment