Question: I need to use a WebView to load certain webpages and dynamically change the css before showing them to the user (which means I have to delete all `<link>` tags and append the one with my css). (Why? Because I want to adapt the look of a particular site - which is not mine - for smartphones)

Now, I've seen that similar questions have been answered that the only way to modify the html before showing it to the user is by executing some javascript in the onPageFinished method; this could be a solution, but I'd like to consider other possibilities as well.

So, my questions are: 

1) If I go deeper in the source of the WebView class, is it possible to find where the html is loaded from the site, so that I have direct access to the html and I can modify it as I want?

2) If yes, is WebView the class that handles the communication and retrieves the html? If else, which one is it?

3) Assuming that what I asked is possible, do you think that the application would perform better if the modification to the html where made this way instead of using javascript?

Answer: 
This is made tricky because of the DoubleClick event. There are a few ways to do this:

1. Handle the double-click event in code behind, and then manually invoke a command/method on your ViewModel
2. Use an attached behavior to route the [DoubleClick event to your Command](https://stackoverflow.com/questions/4629862/attached-behavior-to-execute-command-for-listviewitem)
3. Use a Blend Behavior to [map the DoubleClick event to your command](http://kishordaher.wordpress.com/2009/07/18/routedevent-to-command-action-behavior-blend-3/)

2 and 3 might be more pure, but frankly, 1 is easier, less complex, and not the worst thing in the world. For a one-off case, I'd probably use approach #1. 

Now, if you changed your requirements to use, say, a hyperlink on each item, it would be easier. Start out by naming the root element in your XAML - e.g., for a Window:

```
<Window .... Name="This">

```

Now, in the DataTemplate for your ListBox items, use something like this:

```
<ListBox ...>
  <ListBox.ItemTemplate>
    <DataTemplate>
      <Hyperlink 
        Command="{Binding ElementName=This, Path=DataContext.OpenEntryCmd}"
        Text="{Binding Path=Name}" 
        />

```

The ElementName binding lets you resolve the OpenEntryCmd from the context of your ViewModel, rather than the specific data item.
I recently needed to trigger an `ICommand` upon double clicking a `ListBoxItem` as well.

Personally, I don't like the `DataTemplate` method as it is binding to the content inside the `ListBoxItem` container, and not the container itself. I've opted to use an Attached Property to assign an `InputBinding` on the container. It takes a little more elbow grease, but it works well.

First, we need to create an attached property class. I've created mine a little more generically towards any class that derives from `FrameworkElement`, just in case I run into this again with a different visual.

```
public class FrameworkElementAttachedProperties : DependencyObject
{
    public static readonly DependencyProperty DoubleClickProperty = DependencyProperty.RegisterAttached("DoubleClick", typeof(InputBinding),
        typeof(FrameworkElementAttachedProperties), new PropertyMetadata(null, OnDoubleClickChanged));

    public static void SetDoubleClick(FrameworkElement element, InputBinding value)
    {
        element.SetValue(DoubleClickProperty, value);
    }

    public static InputBinding GetDoubleClick(FrameworkElement element)
    {
        return (InputBinding)element.GetValue(DoubleClickProperty);
    }

    private static void OnDoubleClickChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
    {
        FrameworkElement element = obj as FrameworkElement;

        /// Potentially throw an exception if an object is not a FrameworkElement (is null).

        if(e.NewValue != null)
        {
            element.InputBindings.Add(e.NewValue as InputBinding);
        }
        if(e.OldValue != null)
        {
            element.InputBindings.Remove(e.OldValue as InputBinding);
        }
    }
}

```

Then the final step is to override the base container style for the `ListBoxItem`.

```
<ListBox.ItemContainerStyle>
    <Style TargetType="{x:Type ListBoxItem}"
        BasedOn="{StaticResource ListBoxItem}">
        <Setter Property="local:FrameworkElementAttachedProperties.DoubleClick">
            <Setter.Value>
                <MouseBinding Command="{Binding OnListBoxItemDoubleClickCommand}"
                    MouseAction="LeftDoubleClick"/>
            </Setter.Value>
        </Setter>
    </Style>
</ListBox.ItemContainerStyle>

```

Now, anytime a `ListBoxItem` is double clicked, it will fire our `OnListBoxItemDoubleClickCommand`.