I’m trying to implement a ViewBox displaying a title from the selected ListBox member in the ViewBox. I’m trying to use behaviors, but it doesn’t work within ListBox.ItemTemplate/DataTemplate, only In ListBox, which only responds to being clicked anywhere but the members.
Another thing I’m not sure about which parameter to use, ExecuteCommandOnPointerPressedBehavior or InvokeCommandAction. Any help would be appreciated. View is below:
<Grid>
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="10,0">
<ListBox ItemsSource="{Binding Tasks}" SelectedIndex="{Binding SelectedTaskItem}" Width="500">
<i:Interaction.Behaviors>
<iac:ExecuteCommandOnPointerPressedBehavior Command="{Binding TaskSelectedCommand}" CommandParameter="{Binding SelectedTaskItem}" />
</i:Interaction.Behaviors>
<i:Interaction.Behaviors>
<InvokeCommandAction Command="{Binding TaskSelectedCommand}" CommandParameter="{Binding SelectedTaskItem}" />
</i:Interaction.Behaviors>
<ListBox.Styles>
<Style Selector="ListBoxItem">
<Setter Property="Padding" Value="12 8"></Setter>
</Style>
</ListBox.Styles>
<ListBox.ItemTemplate>
<DataTemplate>
<Border CornerRadius="5"
BorderBrush="Gray"
BorderThickness="1"
Padding="1" Width="500"
HorizontalAlignment="Stretch">
<Grid RowDefinitions="*, *">
<StackPanel Grid.Row="0" Orientation="Horizontal">
<CheckBox Margin="5,0" IsChecked="{Binding IsCompleted}" />
<TextBlock Text="{Binding Title}" Margin="5,10" />
<Ellipse Fill="Purple" Width="12" Height="12" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="1" Margin="15,0">
<Border Margin="15,5" CornerRadius="10" BorderBrush="Gray" BorderThickness="1" Padding="5" Opacity="1">
<TextBlock FontSize="12" Text="Tag" />
</Border>
</StackPanel>
</Grid>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Viewbox IsVisible="True" HorizontalAlignment="Right" Margin="5,0">
<StackPanel>
<Grid RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto, *">
<!-- Title -->
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="5, 10, 5, 5">
<TextBox Text="{Binding SelectedTaskItem.Title}" Width="200" />
</StackPanel>
<TextBlock Height="500" />
</Grid>
<StackPanel Orientation="Horizontal">
<Button Content="Delete" />
</StackPanel>
</StackPanel>
</Viewbox>
</StackPanel>
</Grid>