Reputation: 1207
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 http://cartesia.pbworks.com/f/1260543351/PopUp.png
Upvotes: 0
Views: 456
Reputation: 2652
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.
Upvotes: 2