Search Results

Search found 200 results on 8 pages for 'contextmenu'.

Page 2/8 | < Previous Page | 1 2 3 4 5 6 7 8  | Next Page >

  • Setting style of ContextMenu on subitems

    - by thedesertfox
    I have created a custom style and template for MenuItem and ContextMenu, and for my first level, that works great, but whenever I add a SubMenu item, the style of that ContextMenu reverts back to the default style. How can I make sure that item uses my custom style? I've tried using the <;Style TargetType="ContextMenu" Key="{x:Type ContextMenu}" syntax as well, and it doesn't seem to be overriding it either.

    Read the article

  • How to set a binding in WPF Toolkit Datagrid's ContextMenu CommandParameter

    - by Boris Lipschitz
    I need to create a ContextMenu where I want to pass a currently selected index of the datagrid to a ViewModel using CommandParameter. The following Xaml code doesn't work. What might be the problem? <dg:DataGrid ItemsSource="{Binding MarketsRows}" <dg:DataGrid.ContextMenu > <ContextMenu > <MenuItem Header="Add Divider" CommandParameter="{Binding Path=SelectedIndex, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type dg:DataGrid}}}" Command="{Binding Path= AddDividerCommand}"/> </ContextMenu> </dg:DataGrid.ContextMenu> </dg:DataGrid>

    Read the article

  • How to add Silverlight 4 ContextMenu to DataGrid row using XAML?

    - by Simon_Weaver
    Silverlight 4 has a new ContextMenu control in the latest toolkit. I can't find any examples anywhere on how to reliably use this ContextMenu on a DataGrid row. Theres a tonne of context menus out there but I want to use the new version from the toolkit. I'd like to be able to set context menus for rows as well as cells. The only way I've found is to manually create the menu on right click and show it, but I'd like to do it in XAML. Note: You need to currently use this workaround in the answer to avoid binding problems.

    Read the article

  • WPF: ContextMenu item bound to a Command is enabled only after invoking the command from another so

    - by Brad
    I have a ContextMenu whose items are all bound to commands and enable\disable correctly after ANY Command is invoked from another source but prior to, they are all disabled. So if I run the app, all the MenuItems are disabled but if I invoke any of the bound commands from another source (buttons, for instance) they become synchronized with the CanExecute code. I have no idea how to debug this. Any thought would be helpful!?!

    Read the article

  • DynamicResource and Dynamic Items in ContextMenu on XamDataGrid

    - by miguel
    I would like to dynamically create a set of context menu options based upon some properties. Currently, I am creating a context menu as a DynamicResource with the visibility of the menu options bound to the properties, however, it seems that the DynamicResource is created only once, at runtime. Is this true? What I would like to do is have the menu generated each time, which will take into account the property changes on the data object. Please see the following XAML snippet: <Border DockPanel.Dock="Right" Margin="4,4,4,4" BorderBrush="Gray" BorderThickness="1" CornerRadius="3" > <igDP:XamDataGrid Height="Auto" Width="Auto" Style="{DynamicResource DefaultInfragisticsGridStyle}" Name="axeDataGrid" ActiveRecord="{Binding Path=SelectedItem, Mode=TwoWay}" DataSource="{Binding Path=Axes}" ContextMenuOpening="ContextMenuOpeningHandler"> <igDP:XamDataGrid.Resources> <Style TargetType="{x:Type igDP:DataRecordPresenter}" BasedOn="{x:Static Themes:DataPresenterAero.DataRecordPresenter}"/> <ContextMenu x:Key="RecordContextMenu"> <ContextMenu.Resources> <BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter"/> </ContextMenu.Resources> <MenuItem Header="Cancel Axe" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type igDP:XamDataGrid}}, Path=DataContext.CancelAxe}" Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type igDP:XamDataGrid}}, Path=DataContext.IsCancelAxeAllowed, Converter={StaticResource booleanToVisibilityConverter}, Mode=OneWay}"/> <MenuItem Header="Create RFQ" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type igDP:XamDataGrid}}, Path=DataContext.CreateRFQ}" Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type igDP:XamDataGrid}}, Path=DataContext.IsCreateRfqAllowed, Converter={StaticResource booleanToVisibilityConverter}, Mode=OneWay}"/> </ContextMenu> <Style TargetType="{x:Type igDP:DataRecordCellArea}"> <Setter Property="ContextMenu" Value="{DynamicResource RecordContextMenu}" /> </Style>

    Read the article

  • ActionScript 3 Context Menu Per Sprite?

    - by TheDarkIn1978
    is it not possible to have different context menus for different sprites on the stage? i've tried adding a custom context menu to a sprite but it's applied to the entire stage: mySprite.contextMenu = myMenu; then after reading the documentation where it states: You can attach a ContextMenu object to a specific button, movie clip, or text field object, or to an entire movie level. You use the menu property of the Button, MovieClip, or TextField class to do this. ok, so i though i had to write it like: mySprite.menu.contextMenu = myMenu; only to be greeted with a nice migration issue stating that menu is legacy code and to use contextMenu instead. ??? um, thanks for the headsup, documentation. this process would be entirely much more easier if i could extend the ContextMenu, but for some reason it's marked as "final" and can't be extended... i'm sure adobe's reasons for finalizing the context menu class are as good as their reasons for including misleading documentation. thoughts?

    Read the article

  • AvalonDock + UserControl + DataGrid + ContextMenu command routing issue

    - by repka
    I have this kind of layout: <Window x:Class="DockAndMenuTest.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock" Title="MainWindow" Height="350" Width="525"> <ad:DockingManager> <ad:DocumentPane> <ad:DockableContent Title="Doh!"> <UserControl> <UserControl.CommandBindings> <CommandBinding Command="Zoom" Executed="ExecuteZoom" CanExecute="CanZoom"/> </UserControl.CommandBindings> <DataGrid Name="_evilGrid"> <DataGrid.Resources> <Style TargetType="DataGridRow"> <Setter Property="ContextMenu"> <Setter.Value> <ContextMenu> <MenuItem Command="Zoom"/> </ContextMenu> </Setter.Value> </Setter> </Style> </DataGrid.Resources> </DataGrid> </UserControl> </ad:DockableContent> </ad:DocumentPane> </ad:DockingManager> </Window> Briefly: ContextMenu is set for each DataGridRow of DataGrid inside UserControl, which in its turn is inside DockableContent of AvalonDock. Code-behind is trivial as well: public partial class MainWindow { public MainWindow() { InitializeComponent(); _evilGrid.ItemsSource = new[] { Tuple.Create(1, 2, 3), Tuple.Create(4, 4, 3), Tuple.Create(6, 7, 1), }; } private void ExecuteZoom(object sender, ExecutedRoutedEventArgs e) { MessageBox.Show("zoom !"); } private void CanZoom(object sender, CanExecuteRoutedEventArgs e) { e.CanExecute = true; } } So here's the problem: right-clicking on the selected row (if it it was selected before the right click) my command comes out disabled. The command is "Zoom" in this case, but can be any other, including a custom one. If I get rid of either docking or UserControl around my grid there are no problems. ListBox doesn't have this issue either. So I don't know what's at fault here. SNOOP shows that in cases when this propagation fails, instead of UserControl, CanExecute is handled by PART_ShowContextMenuButton (Button), which is part of docking header. I've had other issues with UI command propagation within UserControls hosted inside AvalonDock, but this one is the easiest to reproduce.

    Read the article

  • Silverlight 4: How to find ContextMenu' s Parent Control from menuitem_click?

    - by funwithcoding
    I have a datagrid and I added silverlight 4 toolkit contextmenu to textbox in datagrid as follows. When users right click on the textbox, contextmenu is being displayed. When users click the menu item with Header "Test", "MenuItem_Click" is getting executed. Now I want to access the textbox from the MenuItem_Click and modify its properties like background etc. Is there anyway to find textbox element(which is contextmenu's parent) from MenuItem_Click event? <my:DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBox Text="{Binding AcctId}" Style="{StaticResource documentTextBoxStyle}" ToolTipService.ToolTip="Right Click to modify parameters" > <toolkit:ContextMenuService.ContextMenu > <toolkit:ContextMenu > <toolkit:MenuItem Header="Test" Click="MenuItem_Click"/> </toolkit:ContextMenu> </toolkit:ContextMenuService.ContextMenu> </TextBox> </DataTemplate>

    Read the article

  • Using MVVM, how to pass SelectedItems of a XamDataGrid as parameter to the Command raised by the Co

    - by saddaypally
    Hi, I'm trying to pass the item on XamDataGrid on which I do a mouse right click to open a ContextMenu, which raises a Command in my ViewModel. Somehow the method that the Command calls is not reachable in debug mode. This is the snipped from the view <ig:XamDataGrid DataSource="{Binding DrdResults}" Height="700" Width="600"> <ig:XamDataGrid.ContextMenu> <ContextMenu DataContext="{Binding RelativeSource={RelativeSource Mode=Self}, Path=PlacementTarget.DataContext}" AllowDrop="True" Name="cmAudit"> <MenuItem Header="View History" Command="{Binding ViewTradeHistory}" CommandParameter="{Binding Path=SelectedItems}"> </MenuItem> </ContextMenu> </ig:XamDataGrid.ContextMenu> <ig:XamDataGrid.FieldSettings> <ig:FieldSettings AllowFixing="NearOrFar" AllowEdit="False" Width="auto" Height="auto" /> </ig:XamDataGrid.FieldSettings> </ig:XamDataGrid> My code in the corresponding ViewModel for this View is as follows public WPF.ICommand ViewTradeHistory { get { if (_viewTradeHistory == null) { _viewTradeHistory = new DelegateCommand( (object SelectedItems) = { this.OpenTradeHistory(SelectedItems); }); } return _viewTradeHistory; } } And lastly the actual method that gets called by the Command is as below private void OpenTradeHistory(object records) { DataPresenterBase.SelectedItemHolder auditRecords = (DataPresenterBase.SelectedItemHolder)records; // Do something with the auditRecords now. } I'm not sure what am I doing incorrectly here. Any help will be very much appreciated. Thanks, Shravan

    Read the article

  • WPF: Exception if i add a eventhandler to a MenuItem (in a ListBox)

    - by user437899
    Hi, i wanted a contextmenu for my ListBoxItems. So i created this: <ListBox Name="listBoxName"> <ListBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding UserName}" /> </DataTemplate> </ListBox.ItemTemplate> <ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem"> <Setter Property="ContextMenu"> <Setter.Value> <ContextMenu> <MenuItem Header="View" Name="MenuItemView" /> </ContextMenu> </Setter.Value> </Setter> </Style> </ListBox.ItemContainerStyle> </ListBox> This works great. I have the contextmenu for all items, but if i want to add a click-eventhandler to the menuitem, like this: <MenuItem Header="View" Name="MenuItemView" Click="MenuItemView_Click" /> I get a XamlParseException when the window is created. InnerException: The Object System.Windows.Controls.MenuItem cannot be converted to type System.Windows.Controls.Grid It throws only the exception if i add a event-handler. The event-method is empty.

    Read the article

  • CheckBox and the ContextMenu

    - by anselmophil
    Hi guys! I have in a ListView with a ContextMenu, it has one CheckBox (the CheckBox has android:focusable="false") and one TextView per row, but you can hide the TextView in the preferences menu. After doing that, the CheckBox wasnt registering the ContextMenu, so of course, why not registerForContextMenu(cb) and unregisterForContextMenu(getListView())? Yes, i did that, but then, when when i call the delete command of onContextItemSelected, the app crashs. AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo(); db.deletarTarefa(info.id); So here i am, accepting ideias and help! :) Thanks

    Read the article

  • DataGrid: How to style or disable the default ContextMenu of a Cell

    - by Nike
    I use DataGrid with DataGridTextColumns. How can I style or disable the default ContextMenu of a Cell? I tried to add a style for DataGridCell: <DataGrid.CellStyle> <Style TargetType="{x:Type DataGridCell}"> <Setter Property="ContextMenu" Value="{x:Null}"/> </Style> </DataGrid.CellStyle> but it doesn't work. As I understand, it is a TextBox inside a Cell when the Cell in edit mode. I tried also to add a style for TextBox, but it have an effect only on TextBoxes in XAML, but not on the DataGrid cells.

    Read the article

  • Identifying the view selected in a ContextMenu (Android)

    - by Casebash
    In Android, onContextItemSelected has a single MenuItem argument and so it isn't clear how to identify the view selected. MenuItem.getMenuInfo provides access to Contextmenu.ContextMenuInfo, but while both known subclasses provide access to the target view, there does not appear to be an accessor on the interface. One alternative is to save the View provided in onCreateContextMenu in a private class variable which relies on onCreateContextMenu not being called again in the activity before onContextItemSelected. Another is to use the id of the View for the itemId argument of ContextMenu.add. If we do this, we would then need to identify the option selected from the context menu by using its (possibly internationalised) title. What is the best method for identifying the View selected in onContextSelected?

    Read the article

  • WP7 - Cancelling ContextMenu click event propagation

    - by Praetorian
    I'm having a problem when the Silverlight toolkit's ContextMenu is clicked while it is over a UIElement that has registered a Tap event GestureListener. The context menu click propagates to the underlying element and fires its tap event. For instance, say I have a ListBox and each ListBoxItem within it has registered both a ContextMenu and a Tap GestureListener. Assume that clicking context menu item2 is supposed to take you to Page1.xaml, while tapping on any of ListBox items themselves is supposed to take you to Page2.xaml. If I open the context menu on item1 in the ListBox, then context menu item2 is on top of ListBox item2. When I click on context menu item2 I get weird behavior where the app navigates to Page1.xaml and then immediately to Page2.xaml because the click event also triggered the Tap gesture for ListBox item2. I've verified in the debugger that it is always the context menu that receives the click event first. How do I cancel the context menu item click's routed event propagation so it doesn't reach ListBox item2? Thanks for your help!

    Read the article

  • how to pass data when using MenuItem.ItemContainerStyle

    - by black sensei
    Hello Experts! i've been trying to have a dynamic ContextMenu to show the name property of each of the object in its collection of objects. here is concrete example ,i'm connecting to a webservice to pull contacts and groups of a particular account.so i have those as global variables.i display the contacts in a listbox and i want to show on right click of a contact in the listbox the list of groups that it can be added to. to be able to add a contact to a group i need the id of the contact(which i have) and the id of the group which i'm looking for here is my code. xmlns:serviceAdmin="clr-namespace:MyWpfApp.serviceAdmin" ...... <ListBox.ContextMenu> <ContextMenu> <MenuItem Header="Refresh" Click="RefreshContact_Click"></MenuItem> <MenuItem Header="Add New Contact" Click="ContactNew_Click"></MenuItem> <MenuItem Header="Add to Group" Name="groupMenus"> //<!--<MenuItem.Resources> // <DataTemplate DataType="{x:Type serviceAdmin:groupInfo}" x:Key="groupMenuKey" > // <MenuItem> // <TextBlock Text="{Binding name}" /> // </MenuItem> // </DataTemplate> // </MenuItem.Resources>--> <MenuItem.ItemContainerStyle> <Style> <Setter Property="MenuItem.Header" Value="{Binding name}"/> <Setter Property="MenuItem.Tag" Value="{Binding id}" /> </Style> </MenuItem.ItemContainerStyle> </MenuItem> <MenuItem Header="Delete Selected" Click="ContactDelete_Click"></MenuItem> </ContextMenu> </ListBox.ContextMenu> ...... and on xaml.cs //this code is in the method that loads the groups loadedgroup = service.getGroups(session.key, null); groupListBox.ItemsSource = loadedgroup; groupMenus.ItemsSource = loadedgroup.ToList(); this code is showing the name of the groups alright but i need the id of the group clicked on. If you've noticed i commented a portion of the xaml code. with that i could bind(with ease) the id to the tag.But it won't work and the MenuItem.ItemContainerStyle is the one working but then i'm lost: Question 1 : how do i create a handler method for a click event of a submenu that has the names of the groups? Question 2 : how do i get the clicked group id to work with? thanks for reading and kindly help me in this

    Read the article

  • Context menu event handling error - CS1061

    - by MrTemp
    I am still new to c# and wpf This program is a clock with different view and I would like to use the context menu to change between view, but the error says that there is no definition or extension method for the events. Right now I have the event I'm working on popping up a MessageBox just so I know it has run, but I cannot get it to compile. public partial class MainWindow : NavigationWindow { public MainWindow() { //InitializeComponent(); } public void AnalogMenu_Click(object sender, RoutedEventArgs e) { /*AnalogClock analog = new AnalogClock(); this.NavigationService.Navigate(analog);*/ } public void DigitalMenu_Click(object sender, RoutedEventArgs e) { MessageBox.Show("Digital Clicked"); /*DigitalClock digital = new DigitalClock(); this.NavigationService.Navigate(digital);*/ } public void BinaryMenu_Click(object sender, RoutedEventArgs e) { /*BinaryClock binary = new BinaryClock(); this.NavigationService.Navigate(binary);*/ } } and the xaml call if you want it <NavigationWindow.ContextMenu> <ContextMenu Name="ClockMenu" > <MenuItem Name="ToAnalog" Header="To Analog" ToolTip="Changes to an analog clock"/> <MenuItem Name="ToDigital" Header="To Digital" ToolTip="Changes to a digital clock" Click="DigitalMenu_Click" /> <MenuItem Name="ToBinary" Header="To Binary" ToolTip="Changes to a binary clock"/> </ContextMenu> </NavigationWindow.ContextMenu>

    Read the article

  • no longer an issue

    - by MrTemp
    I am still new to c# and wpf This program is a clock with different view and I would like to use the context menu to change between view, but the error says that there is no definition or extension method for the events. Right now I have the event I'm working on popping up a MessageBox just so I know it has run, but I cannot get it to compile. public partial class MainWindow : NavigationWindow { public MainWindow() { //InitializeComponent(); } public void AnalogMenu_Click(object sender, RoutedEventArgs e) { /*AnalogClock analog = new AnalogClock(); this.NavigationService.Navigate(analog);*/ } public void DigitalMenu_Click(object sender, RoutedEventArgs e) { MessageBox.Show("Digital Clicked"); /*DigitalClock digital = new DigitalClock(); this.NavigationService.Navigate(digital);*/ } public void BinaryMenu_Click(object sender, RoutedEventArgs e) { /*BinaryClock binary = new BinaryClock(); this.NavigationService.Navigate(binary);*/ } } and the xaml call if you want it <NavigationWindow.ContextMenu> <ContextMenu Name="ClockMenu" > <MenuItem Name="ToAnalog" Header="To Analog" ToolTip="Changes to an analog clock"/> <MenuItem Name="ToDigital" Header="To Digital" ToolTip="Changes to a digital clock" Click="DigitalMenu_Click" /> <MenuItem Name="ToBinary" Header="To Binary" ToolTip="Changes to a binary clock"/> </ContextMenu> </NavigationWindow.ContextMenu>

    Read the article

  • CF ContextMenu - (onOpen event???)

    - by no9
    Hello ! I have a CF application. In some view i have a ContextMenu that shows OK. Is there a way to catch an event as the menu is drawn/opened? I need to do some things just as the menu is drawn, because doing it later (on menuitem click) is already too late. regards

    Read the article

  • ICommand.CanExecute being passed null even though CommandParameter is set...

    - by chaiguy
    I have a tricky problem where I am binding a ContextMenu to a set of ICommand-derived objects, and setting the Command and CommandParameter properties on each MenuItem via a style: <ContextMenu ItemsSource="{Binding Source={x:Static OrangeNote:Note.MultiCommands}}"> <ContextMenu.Resources> <Style TargetType="MenuItem"> <Setter Property="Header" Value="{Binding Path=Title}" /> <Setter Property="Command" Value="{Binding}" /> <Setter Property="CommandParameter" Value="{Binding Source={x:Static OrangeNote:App.Screen}, Path=SelectedNotes}" /> ... However, while ICommand.Execute( object ) gets passed the set of selected notes as it should, ICommand.CanExecute( object ) (which is called when the menu is created) is getting passed null. I've checked and the selected notes collection is properly instantiated before the call is made (in fact it's assigned a value in its declaration, so it is never null). I can't figure out why CanEvaluate is getting passed null.

    Read the article

  • Silverlight 4: How to find source UI element from contextmenu's menuitem_click?

    - by funwithcoding
    I have a datagrid and I added silverlight 4 toolkit contextmenu to textbox in datagrid as follows. When users right click on the textbox, contextmenu is being displayed. When users click the menu item with Header "Test", "MenuItem_Click" is getting executed. Now I want to access the textbox from the MenuItem_Click and modify its properties like background etc. Is there anyway to find textbox element(which is contextmenu's parent) from MenuItem_Click event? It appears to me that I am missing something very simple. <my:DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBox Text="{Binding AcctId}" Style="{StaticResource documentTextBoxStyle}" ToolTipService.ToolTip="Right Click to modify parameters" > <toolkit:ContextMenuService.ContextMenu > <toolkit:ContextMenu > <toolkit:MenuItem Header="Test" Click="MenuItem_Click"/> </toolkit:ContextMenu> </toolkit:ContextMenuService.ContextMenu> </TextBox> </DataTemplate>

    Read the article

  • Save as Ringtone from ContextMenu

    - by kostas_menu
    I have created a button that onClick plays a mp3 file.I have also create a context menu that when you press the button for 2 secs it prompts you to save it as ringtone.How can i save it somewhere in my sd?this is my code: public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); Toast.makeText(a.this, "Touch and listen", Toast.LENGTH_SHORT).show(); Button button = (Button) findViewById(R.id.btn1); registerForContextMenu(button); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v){ MediaPlayer mp = MediaPlayer.create(a.this, R.raw.myalo); mp.start(); Toast.makeText(a.this, "Eisai sto myalo", Toast.LENGTH_SHORT).show(); } }); @Override public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); menu.setHeaderTitle("Save As:"); menu.add(0, v.getId(), 0, "Ringtone"); } @Override public boolean onContextItemSelected(MenuItem item) { if(item.getTitle()=="Ringtone"){function1(item.getItemId());} else {return false;} return true; } public void function1(int id){ Toast.makeText(this, "Ringtone Saved", Toast.LENGTH_SHORT).show(); } }

    Read the article

  • "x" To Minimize WinForm, ContextMenu To Close WinForm?

    - by Soo
    Hi SO, I have a WinForm that I want to minimize when the "x" in the top right corner is clicked. To accomplish this, I have: private void Form_FormClosing(object sender, FormClosingEventArgs e) { e.Cancel = true; WindowState = FormWindowState.Minimized; } That's all well and good, but now I have a context menu that has the option to close the WinForm, but because of the code above, it simply minimizes the window. How can I get everything to work the way I want it to?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8  | Next Page >