1
<ItemsControl ItemsSource="{Binding Vwr.Table.Vals, UpdateSourceTrigger=PropertyChanged}">
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
            <TextBlock x:Name="SearchCol" Text="{Binding Col}" Style="{StaticResource tabTextBlock}"/>
            <TextBox x:Name="SearchText" Text="{Binding Filter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="200">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="TextChanged">
                        <i:InvokeCommandAction Command="{Binding Path=DataContext.Modules.SelectedModule.Vwr.Table.ExpandBoMCommand, RelativeSource={RelativeSource Mode=FindAncestor,
                                     AncestorType={x:Type Window}}, UpdateSourceTrigger=PropertyChanged}" CommandParameter="{Binding Col}"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </TextBox>
            <TextBlock Text="{Binding CTStr}" Style="{StaticResource tabTextBlock}"/>
            </StackPanel>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

Update

I'm close! I've found a way to get my data where it needs to go, now my issue is accessing both pieces of data. Command Parameter can only pass one.

Update 2

I passed the entire dataItem

Tristan
  • 96
  • 13

1 Answers1

2

To make this work in WPF you have at least couple options:

Option 1:

  1. Set DataContext for your ItemsControl
  2. Bind ItemsControls ItemsSource
  3. Give name to your ItemsControl
  4. Bind your command using ElementName and Path

For steps 1-3, you can use the following example:

<ListView DataContext="{Binding MyVm}" x:Name="Items" ItemsSource="{Binding Items}" IsItemClickEnabled="False">

For step 4:

<core:InvokeCommandAction Command="{Binding ElementName=Items, Path=DataContext.MyCommand}"/>

Option 2:

Use RelativeSource AncestorType binding in your command.

Mikael Koskinen
  • 12,306
  • 5
  • 48
  • 63