How do I dynamically bind and statically add MenuItems?

You can use a CompositeCollection to do this, you can combine different Collections and add static items in the xaml. Example: Xaml: <Window x:Class=”WpfApplication8.MainWindow” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Title=”MainWindow” Height=”233″ Width=”143″ Name=”UI”> <Window.Resources> <CollectionViewSource Source=”{Binding ElementName=UI, Path=Windows}” x:Key=”YourMenuItems”/> </Window.Resources> <Grid DataContext=”{Binding ElementName=UI}”> <Menu Height=”24″ VerticalAlignment=”Top”> <MenuItem Header=”_View” > <MenuItem Header=”Windows”> <MenuItem.ItemsSource> <CompositeCollection> <CollectionContainer Collection=”{Binding Source={StaticResource YourMenuItems}}” /> … Read more

Custom view for Menu Item

What you need to do is create a layout file with the view that you want for the item, the when you declare the item on the menu, assign the layout like this: <item android:id=”@+id/menu_pick_color” android:title=”@string/pick_color” app:showAsAction=”always” app:actionLayout=”@layout/my_custom_item”/> And that’s it! EDIT: To access the custom item and modify it’s color at runtime you can … Read more

android: changing option menu items programmatically

For anyone needs to change the options of the menu dynamically: private Menu menu; // … @Override public boolean onCreateOptionsMenu(Menu menu) { this.menu = menu; getMenuInflater().inflate(R.menu.options, menu); return true; } // … private void hideOption(int id) { MenuItem item = menu.findItem(id); item.setVisible(false); } private void showOption(int id) { MenuItem item = menu.findItem(id); item.setVisible(true); } private … Read more

System.Windows.Controls.MenuItem without icon area

You can achieve it by defining ItemsPanel property of MenuItem. Create an ItemsPanelTemplate resource <ItemsPanelTemplate x:Key=”MenuItemPanelTemplate”> <StackPanel Margin=”-20,0,0,0″ Background=”White”/> </ItemsPanelTemplate> Add below MenuItem style to resources and you are done. <Style TargetType=”{x:Type MenuItem}”> <Setter Property=”ItemsPanel” Value=”{StaticResource MenuItemPanelTemplate}”/> </Style> To apply same Style to a ContextMenu, you need to create one more Style as following- <Style … Read more

Mutually exclusive checkable menu items?

This may not be what you’re looking for, but you could write an extension for the MenuItem class that allows you to use something like the GroupName property of the RadioButton class. I slightly modified this handy example for similarly extending ToggleButton controls and reworked it a little for your situation and came up with … Read more

Set anonymous/dynamic functions to Menu

Summary: Google apps script runs in a stateless environment. Anything stored in global object is not maintained across sessions. If you add something to the global object during a session, it is not available in the next session run. Use Immediately Invoked Functions or Call functions in global scope to fill the global scope(this object) … Read more