views:

69

answers:

1

I have a ComboBoxItem [Line Color] that displays a PopUp on IsHighlighted and I want to eat the click on the ComboBoxItem. I know how to do it programmatically but I was wondering if there's any way to accomplish this in XAML?

alt text

+1  A: 

I don't think you can do this without some code for a handler. You could write some inline code within the xaml if you were just concerned with keeping it in a single file, but it would still need to be compiled pretty much as if it was written in code-behind.

Inline code example from MSDN:

<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="MyNamespace.MyCanvasCodeInline"
>
  <Button Name="button1" Click="Clicked">Click Me!</Button>
  <x:Code><![CDATA[
    void Clicked(object sender, RoutedEventArgs e)
    {
        button1.Content = "Hello World";
    }
  ]]></x:Code>
</Page>

You could do something like this to handle PreviewMouseDown in the .xaml file, but are you still using some (non-XAML) code to accomplish it.

Ben Collier
Thanks Ben. I'm only concerned with code-behind in the sense that I want to try to push the XAML as far as possible but not to the extent that it becomes tortured! <g>
Brad
By the by, I didn't know you could inline, so thank you!
Brad