checkable menu items - contextmenu

i have a contextmenu. how can i make it checkable?
System.Windows.Controls.MenuItem does not contain a definition for IsCheckable.

I think it already is checkable. At least according to msdn:
http://msdn.microsoft.com/en-us/library/system.windows.controls.menuitem.ischeckable%28v=VS.85%29.aspx

Related

Umbraco 7.5.1 umbracoNaviHide

To be able to filter out items that should not be rendered with .Where("Visible") I need a property called umbracoNaviHide that returns true or false.
In earlier versions this was added to the Generic tab. However now you cant append to that tab anymore.
How would I accomplish hiding pages now?
Here's my foreach:
#foreach (var Area in Model.Content.Children.Where("Visible"))
{
Here's a statement about it. But I cant find any workaround.
Related Changes Summary - 7.4 beta - Option toCannot add properties to the "Generic properties" tab
Description - In the 7.4 beta it's not possible anymore to add
properties to the "Generic properties" tab. I know this has been done
because properties can be a bit hidden on that tab and usually are
better on a separate tab. But there are situations where the
properties are better on that tab.
You can add that property as a true/false datatype to any tab. However, it's important to note that umbracoNaviHide does not do anything special it is just a magic string, that, when implemented as a true/false datatype, it works with
.Where("Visible").
Personally I don't use it anymore. If I need to cause items to be visible or not then I would name the property more specifically. For example, it is often useful when implementing menus where you want some nodes to be visible but not others. I generally have a Menu tab where one of the properties is a true/false type called Show in menu with an alias of showInMenu.
In code it could be something like below (I have used TypedContentAtXPath to get the parent node of a specific doc type. Of course there are various ways of doing this)
var homeNode = Umbraco.TypedContentAtXPath("//MyHomePageDocType").First();
var menuItems = homeNode.Children.Where(item=>item.GetPropertyValue<bool>("showInMenu"));
foreach(var item in menuItems)
{
// Do your menu stuff here
}
Hope that helps
J
You can create a composition for node visibility with a checkbox to show or hide the menu item. And you can inherit this to the doc types that you do not want to show.
And then you can do
_homeNode.Children.Where(x => !x.GetPropertyValue<bool>("hideInNavigation"));
Hope this helps!

TImageList.ShareImages - How to use exactly to not have to copy the content?

I use C++ Builder, but the question is just as relevant for Delphi I believe.
When I have two TImageList objects and at some point I want to use the same icons in both image lists, I can copy the content: ImageList2.Assign(ImageList1) ;
However, I noticed TImageList.ShareImages in Help suggesting I can use the same internal list, and save resources copying !? Poorly documented however because I'm not sure how I can achieve this exactly ?
What do I do to make ImageList2 use the same internal list as ImageList1 ? (I would set ImageList2.ShareImages = true then.
As I read the source code, you do it like this:
ImageList2->Handle = ImageList1->Handle;
ImageList2->ShareImages = true;
All that ShareImages controls is whether or not the image list handle is owner by the list. In this case it is owned by ImageList1 and not by ImageList2.
A consequence of this is that ImageList1 must out live ImageList2. Otherwise if ImageList1 is destroyed first, then ImageList2 is left holding on to a handle of an image list that has been destroyed.

De-queue and linked list

I want to know what a de-queue is?
Is it same as a linked list?
If yes then,
Is it something like "de-queue can be represented as a linked list" ?
or
Is de-queue a "singly linked list" or "double linked list" (like alias to anyone of them)??
de-queue is Double-ended queue. In queue you have two basic operations:
1. Add element at the end of queue
2. Remove element from start of the queue.
de-queue supports total four basic operations:
1. Add element at start.
2. Remove element from start.
3. Add element at end.
4. Remove element from end.
Of course you can add other functionality like getting the value of first or last element without removing it etc.
You can implement de-queue using any data structure but efficient implementations are done using dyanmic array or doubly linked list. For more details follow this link http://en.wikipedia.org/wiki/Double-ended_queue

Mustache - how can I do something *once* for an iterable?

Say I have a user, who has many items
How can I have a single 'Sweet, you have items!', provided there's at last one item in items?
{{#user.items}}
Sweet, you have items!
{{/user.items}}
Note: I know I can create a section that will repeat for each item. But right now I don't want to do that.
The answer (like most things Mustache) is "prepare your view model before rendering" :)
But if you're not into that, you can usually fake it in Mustache.js like this:
{{# user.items.0 }}
Sweet, you have items!
{{/ user.items.0 }}
(The more Mustachey way would be to add a hasItems property or function to the user and use that instead)
Edit: {{# user.items.length }} does the same thing, and doesn't pollute your context stack quite as much. You should use that instead.
Well, really, you should use a view model. But second best would be user.items.length.

Select Multiple, get selected values and non-selected values

I have a select multiple on my page. The user can add elements to the list and remove them selecting one or more.
When I get the select's value through params.selectName, I receive only the selected ones. I
understand that this is the default behavior, but I need all of them, not only selected elements.
I don't really want to select all elements each time I send data to server. Does anyone have a better solution? Thanks.
The approach taken by the <g:checkBox> tag is to create a hidden field with the same name as the checkbox but with an underscore prepended. You could use a similar trick here, i.e. whenever you add a new <option> to the <select> you also add a hidden field named (say) selectName_options with the same value. Then in the controller you can take the difference between params.list('selectName') and params.list('selectName_options') to get the un-selected options from the list.
This is a bit of a complex solution to what should be a simple problem, but in my current project we just had the same problem and solved it as #cdeszaq describes.
Assuming an object of class Foo with a collection (bars) of Bar items, where each Bar has a String name and outputs it as its toString() representation, we do this in the FooController:
def removedItems = fooInstance.bars.findAll {
!params.bars.collect { it.key }.contains(it.name)
}
if(removedItems){
removedItems.each {
fooInstance.removeFromBars(it)
}
}

Resources