Good Afternoon,
I try to Bind the Tag Property of a ThemedDataGrid ContextMenu Button to the Grids SelectedIndex...
All I get is : Error: 4 : Cannot find source for binding with reference 'ElementName=processDataGrid'. BindingExpression:Path=SelectedIndex; DataItem=null; target element is 'Button' (Name=''); target property is 'Tag' (type 'Object')
The Goal: My Command should receive the SelectedIndex or better the SelectedItem as a Paramter.
Here is my approach
<datagrid:ThemedDataGrid x:Name="processDataGrid" AutoGenerateColumns="False" ItemsSource="{Binding ProcessList}" SelectionMode="Single">
<datagrid:ThemedDataGrid.ContextMenu>
<ribbon:ContextMenu>
<StackPanel>
<ribbon:Menu>
<ribbon:Separator Label="Processes" />
<ribbon:Button Label="Watch this" ImageSourceSmall="Ressources/Images/16/process-browse.png"
Command="{Binding AddWatchCommand}"
Tag="{Binding SelectedIndex, ElementName=processDataGrid}"/>
</ribbon:Menu>
</StackPanel>
</ribbon:ContextMenu>
</datagrid:ThemedDataGrid.ContextMenu>
<datagrid:ThemedDataGrid.Columns>
<DataGridTextColumn x:Name="ProcessName" Binding="{Binding ProcessName}" Header="Process Name" Width="*" />
<DataGridTextColumn x:Name="Id" Binding="{Binding Id}" Header="Process Id" Width="75" />
<DataGridTextColumn x:Name="Responding"
Binding="{Binding Responding, Converter={StaticResource ProcessRespondingToTextConverter}}"
Header="Responding" Width="100" />
<DataGridTextColumn x:Name="TotalProcessorTime" Binding="{Binding TotalProcessorTime}"
Header="Total Processor Time" Width="150" />
<DataGridTextColumn x:Name="WorkingSet64"
Binding="{Binding WorkingSet64, Converter={StaticResource FileSizeConverter}}"
Header="Working-Set 64" Width="150" />
</datagrid:ThemedDataGrid.Columns>
</datagrid:ThemedDataGrid>