|
I hope that this helps:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns: d="http://schemas.microsoft.com/expression/blend/2006"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="ListViewContextSample.Window1"
x:Name="Window"
Title="Window1"
Width="640" Height="480">
<Window.Resources>
<XmlDataProvider x:Key="WPFRSSFeed" d:IsDataSource="True"
Source="http://www.codeproject.com/WebServices/MessageRSS.aspx?fid=1004114"/>
<DataTemplate x:Key="itemTemplate">
<StackPanel>
<TextBlock Text="{Binding Mode=OneWay, XPath=title}"/>
<TextBlock Text="{Binding Mode=OneWay, XPath=description}"/>
<TextBlock Text="{Binding Mode=OneWay, XPath=link}"/>
<TextBlock Text="{Binding Mode=OneWay, XPath=author}"/>
<TextBlock Text="{Binding Mode=OneWay, XPath=pubDate}"/>
<TextBlock Text="{Binding Mode=OneWay, XPath=subject}"/>
</StackPanel>
</DataTemplate>
</Window.Resources>
<StackPanel x:Name="LayoutRoot">
<ScrollViewer IsTabStop="True" >
<ItemsControl ItemTemplate="{DynamicResource itemTemplate}"
ItemsSource="{Binding Mode=Default, Source={StaticResource WPFRSSFeed},
XPath=/rss/channel/item}">
<ItemsControl.ContextMenu>
<ContextMenu Name="MyContextMenu">
<MenuItem Header="This is my menu" />
</ContextMenu>
</ItemsControl.ContextMenu>
</ItemsControl>
</ScrollViewer>
</StackPanel>
</Window>
modified on Tuesday, September 2, 2008 5:05 AM
|
|
|
|
|
I have written like this..
<window x:class="WpfApplication2.Window1" xmlns:x="#unknown">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<grid>
<listbox height="70" verticalalignment="Top"> <listbox.contextmenu> <contextmenu>
<menuitem header="Send" click="MenuItem_Click">
<listboxitem>ListViewItem
This enables Contextmenu for the listBox. But i want to enable Context menu only for list box items...Is it Possible?
Santhapur
|
|
|
|
|
Santhapur - I can't see your code. Could you post it again using the < and > tags instead?
|
|
|
|
|
<Window x:Class="WpfApplication2.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<ListBox Height="70" VerticalAlignment="Top">
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem Header="Send" Click="MenuItem_Click"/>
</ContextMenu>
</ListBox.ContextMenu>
<ListBoxItem>Santhapur</ListBoxItem>
</ListBox>
</Grid>
</Window>
Santhapur
|
|
|
|
|
Santhapur - the easy way to do this is to blow the ListBoxItem open a bit. Consider the following bit that replaces the entry in the ListBox section.
<ListBoxItem>
<ListBoxItem.Content>
<TextBlock Text="Santhapur">
<TextBlock.ContextMenu>
<ContextMenu>
<MenuItem Header="Send" />
</ContextMenu>
</TextBlock.ContextMenu>
</TextBlock>
</ListBoxItem.Content>
</ListBoxItem> That should do it for you. The context menu is now associated with the textblock, which is the list box item.
|
|
|
|
|
|
You're welcome. Don't you just love WPF? So many ways you can do things - and easier to get at EXACTLY the thing you want to do, rather than having to fight your way through APIs.
|
|
|
|
|
I am using
<listBox>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
</grid>
</DataTemplate>
</ListBox.ItemTemplate>
</listBox>
I wrote context menu inside the Grid tags. But i am not getting the menu on it..
can any one help
|
|
|
|
|
HI
I have a .xaml file which contains view box which in tearn contains some graphics using WPF.Shapes. I have handdled few events (eg Click event of Path etc).
Now I want to shift this file in a resource and use in my user control. Is it possble to get the events definded in the xaml inside the user control and can I access the veiwbox form the xaml inside my user control?
|
|
|
|
|
Yes to everything, no problem. Works just like you are in a window.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Karl's Back!!!!! Wooo! Welcome fella!
|
|
|
|
|
It certainly is good to see the Molenator back, and now a Microsoftie - oh how I wish. Way to go Karl.
|
|
|
|
|
Jammer,
Thanks for the Woooo!!!
Check my blog on Friday, XAMLPowerToys!!
modified 27-Feb-21 21:01pm.
|
|
|
|
|
No bother!!
I just checked your blog (it's friday here!) and no XAMLPowerToys so I'm going to go sulk in the corner until they appear ...
|
|
|
|
|
Jammer,
I added a new feature late last night and need just a little more testing time.
Shooting for Saturday, Sunday at the latest.
Dude, you'll be glad I took an extra day!
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Hmmm. Now you've got me wondering.
|
|
|
|
|
I just keep thinking about features!!!! AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH.
Promise to stop adding features after tomorrow and get it out the door.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
I made the mistake of talking to somebody yesterday about a WPF calendar control. Now, I just have to write one (well, I started one last night).
|
|
|
|
|
Just ... one ... more ... thing ... doh!!
|
|
|
|
|
I'm now trying to write a lookless calendar control. I'm guessing that I'm going to have to stop adding features at some point, but WPF just makes it so damn easy.
|
|
|
|
|
|
Hey guys...
As you may or may not know im busy working on a WPF calender / roster control.
At the moment ive got the logic that changes the day numbers on the cells when month or year changes, i context menu that pops up when a day cell that has a number is right clicked, and once an entry is chosen the style changes accordingly.
the next step would be to select a day by left clicking it, this is for some "copy and paste" functionality.
the idea is to add some kind of a style or effect over the cells existing style, kind of like when you select an icon on your pc.
any ideas would be appreciated...
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
Highlight it? Change colour of the cell/border. Alternatively, and one that is simple in WPF, expand the size of the cell and put a shadow under it to make it look 3D.
|
|
|
|
|
Pete O'Hanlon wrote: Change colour of the border
why didnt I think of that i think that will do nicely, and maybe even thiken the border a little.
Pete O'Hanlon wrote: expand the size of the cell and put a shadow under it to make it look 3D.
sounds cool, but i dont think it will work in this situation cause more than one cell will be selected at the same time.
Thanx master Yoda
TTYL
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
Harvey Saayman wrote: Pete O'Hanlon wrote:
expand the size of the cell and put a shadow under it to make it look 3D.
sounds cool, but i dont think it will work in this situation cause more than one cell will be selected at the same time.
Hmmm. I may just have to play with this. Maybe there's an article in it.
And, you're welcome.
|
|
|
|