Show appbar button if item is selected - list

I am writing an app with an appbar and item list. I want to add some buttons to the appbar which should appear only when the list item is selected.
So, how to show an additional button on an appbar when the item of the list is selected?
This is Windows 8 Metro style C#/XAML application.

<AppBar x:Name="bottomAppBar" IsOpen="True" IsSticky="True">
...
private void itemGridView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (itemGridView.SelectedItems.Count > 0)
{
nextButton.Visibility = Windows.UI.Xaml.Visibility.Visible;
}
else
{
nextButton.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
}
}

Create the additional app bar button and set its Visibility property to Collapsed.
In the SelectionChanged event handler of the list, set the buttons Visibility property to either Visible or Collapsed depending on whether the list item is being selected or deselected.

Set AppBar.IsOpen property instead of Visibility.

Related

Sitecore custom ribbon button not working

I have created a custom ribbon button following the steps mentioned in http://jondjones.com/how-to-add-a-custom-sitecore-button-to-the-editor-ribbon/
I can see the button appearing in sitecore:
Custom button
Command does not get triggered when clicked on the button.
Below is my code:
using System;
using Sitecore.Shell.Applications.Dialogs.ProgressBoxes;
using Sitecore.Shell.Framework.Commands;
namespace SitecoreVsPoc.Commands
{
public class TranslateContent : Command
{
private static readonly object Monitor = new object();
public override void Execute(CommandContext context)
{
if (context == null)
return;
try
{
ProgressBox.Execute("Arjun", "Title", "Applications/32x32/refresh.png", Refresh);
}
catch (Exception ex)
{
Sitecore.Diagnostics.Log.Error("Error!", ex, this);
}
}
public void Refresh(params object[] parameters)
{
// Do Stuff
}
}
}
Below is the command I have registered in commands.config:
<command name="contenteditor:translatecontent" type="SitecoreVsPoc.Commands.TranslateContent,SitecoreVsPoc" />
Note: I am using Sitecore 8.2 initial release.
Can someone suggest a solution for this?
In Sitecore 8 it was changed the way you add Ribbon button. As far I see your link is from Sitecore 7 or 6.
To create the new button item for the Experience Editor ribbon:
In the Core database, open the Content Editor and navigate to /sitecore/content/Applications/WebEdit/Ribbons/WebEdit/Page Editor/Edit.
Create a new item based on the relevant ribbon control template, for example, the Small Button template. The templates are located at /sitecore/templates/System/Ribbon/.
For the new item, add the following information:
In the Header field, enter the display name of the button.
In the ID field, enter a unique identifier for the item. For example, you can include the ribbon group name in the ID.
In the Icon field, enter the path to the relevant icon. Depending on the button you create, adjust the icon size accordingly.
Open Sitecore Rocks and add the relevant control rendering, for example SmallButton, to the layout of the button item you created.
Enter a unique ID for the rendering.
For other SPEAK controls, you can point to another item in the Data Source field and specify the configuration in this other item.
Important
More informations you can find here: https://doc.sitecore.net/sitecore_experience_platform/content_authoring/the_editing_tools/the_experience_editor/customize_the_experience_editor_ribbon
http://reyrahadian.com/2015/04/15/sitecore-8-adding-edit-meta-data-button-in-experience-editor/
Before it was very simple, you didn't need to add new code:
https://blog.istern.dk/2012/05/21/running-sitecore-field-editor-from-a-command/

Flex Change List Item Selected While Mouse Down

I am trying to create a List which behaves like, for example, the Finder Menu on my Mac. In other words if I click on a List Item, keep my mouse down and move up and down the List I want the Selected Item to change.
In my Flex application if I click on my List and then, with the mouse still down, move up and down the List the Selected Item remains the same.
Any advice would be gratefully received.
Thanks
In StackOverflow tradition I am posting a solution to my own problem after working at it more:
I had an ItemRenderer on my List. In the ItemRenderer I declared a variable to hold a reference to the owning List.
private var _parentList:List;
In the 'set data' function I set this variable to the owner List.
override public function set data(value:Object):void {
super.data = value;
// Check to see if the data property is null.
if (value == null)
return;
// If the data property is not null.
// Get a reference to the parent list.
_parentList = this.owner as List;
...
I then added an EventListener to listen for MouseDown events.
// Attach an eventListener to the ItemRenderer.
this.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
...
My onMouseOver handler looks like this.
private function onMouseOver(event:MouseEvent):void {
//trace(data.LocationName);
if (event.buttonDown == true) {
_parentList.selectedIndex = itemIndex;
}
}
So with this in place I can mouse-down on my List and keeping the mouse button depressed move up and down the List with the List Item beneath the cursor always being selected. The final piece to this is to ensure that the List responds to the selectedIndex being set by the ItemRenderer. When the user changes the selectedIndex property by interacting with the control, the control dispatches the change and changing events. When you change the value of the selectedIndex property programmatically, it dispatches the valueCommit event. To ensure I responded to my programmatic changing of the selected list item I added a handler to the valueCommit event.
<s:List
id="locationsList"
dataProvider="{presenter.locations}"
itemRenderer="itemrenderers.locationListItemRenderer"
useVirtualLayout="false"
width="1869.698" height="1869.698"
y="65.151" x="65.151"
borderVisible="true"
borderColor="{presenter.backgroundColour}"
contentBackgroundAlpha="0"
contentBackgroundColor="0xff336c"
labelField="label"
change="presenter.onLocationListChange(event)"
valueCommit="presenter.onLocationListValueCommit(event)">
<s:layout>
<s:BasicLayout />
</s:layout>
</s:List>
So far it seems to work fine. Hope it helps.

Sitecore SPEAK UI set selected row of ListControl

I have a SPEAK UI dialog with a ListControl bound to a custom JSON datasource. This works and the ListControl is correctly populated. My JSON data looks something like this:
[
{
"itemId":"{BA26159A-194D-4A3C-9D1A-DA9472F11BE0}",
"selected":true
},
{
"itemId":"{E651D0CD-0E7E-4903-8E26-0D1D5A168E69}",
"selected":false
},
{
"itemId":"{E651D0CD-0E7E-4903-8E26-0D1D5A168E70}",
"selected":false
}
]
Is there a way to ensure the relevant row of the ListControl is selected ("selected":true) when the dialog loads?
You can set the ListControl's selected item ID like this: this.MediaResultsListControl.viewModel.set({selectedItemId:"ITEMID"})
(Sitecore.Speak.app instead of this during dubuging in the console)
If you call this.MediaResultsListControl.viewModel.selectedItemId() you can see the selected item has been set by the above method.
Wondering on page load, if you can set the ListControls selected item id, from the page code manually using this method?
Looking at the JS for the list control. It calls this on click of a row. Wonder if you can replace this to trigger selected row?
selectRow: function (row, rowModel) {
this.$el.find(".active").removeClass("active");
row.addClass("active");
this.model.set("selectedItem", rowModel);
this.model.set("selectedItemId", rowModel.get("itemId"));
},

How To Create A CheckBoxList in Maya

i want to create a checkbox list in Autodesk Maya (MEL only) which contains N number of items along with a check/ uncheck option next to it. so that on click of a button i can get value of all checked or unchecked items. There is a component called textscrolllist but it does not support checkbox.
Check out the "Controls" category in the MEL reference, you will find the checkBox and checkBoxGroup commands. You can query the state with the -value or -valueN flags.
Check out this site. This has helped me over the past few years when it comes to creating custom UIs in mel. Below is some block text on how to create a checkbox within a UI.
https://nccastaff.bournemouth.ac.uk/jmacey/RobTheBloke/www/mel/GUI_controls.html
// a function to be called when the checkbox gets checked.
proc on_func() {
print("checkbox on!\n");
}
// a function to be called when the checkbox gets unchecked.
proc off_func() {
print("checkbox on!\n");
}
{
// create a window
window;
// define the layout of controls added
// to the window.
columnLayout;
// create a checkbox
$c = `checkBox -label "thingy"
-onCommand "on_func"
-offCommand "off_func"`;
// show the window we last created
showWindow;
// to get the current value of the checkBox, use the -query flag
$value = `checkBox -query -value $c`;
print("check_box value = "+ $value +"\n");
}

How to split a Window dynamically in MFC without using CSplitterWnd::Create

I create a MFC MDI application, and want to split a window into two parts at a time dynamically by right click and choosing a "AddSplitWnd" pop menu item. I try to use CSplitterWnd::CreateStatic to implement it, once the window is split, it need to create a new view, but I want to use the previous view instead, so does anyone know how to implement it. Thank you.
Here is a code snippet to exchange views in a splitter in a SDI environment. This should be adaptable to work in MDI as well.
CView* CDoc::SwitchToView(CView* pNewView)
{
CFrameWndEx* pMainWnd = (CFrameWndEx*)AfxGetMainWnd();
CView* pOldActiveView;
pOldActiveView = pMainWnd->GetActiveView();
CSplitterWnd* pSplitter = (CSplitterWnd *)pOldActiveView->GetParent();
// in this case Pane 0,0 is exchanged
pOldActiveView = (CView*) pSplitter->GetPane(0,0);
// set flag so that document will not be deleted when view is destroyed
m_bAutoDelete = FALSE;
// Dettach existing view
RemoveView(pOldActiveView);
// set flag back to default
m_bAutoDelete = TRUE;
// Set the child window ID of the active view to the ID of the corresponding
// pane. Set the child ID of the previously active view to some other ID.
::SetWindowLong(pOldActiveView->m_hWnd, GWL_ID, 0);
::SetWindowLong(pNewView->m_hWnd, GWL_ID, pSplitter->IdFromRowCol(0,0));
// Show the newly active view and hide the inactive view.
pNewView->ShowWindow(SW_SHOW);
pOldActiveView->ShowWindow(SW_HIDE);
// Attach new view
AddView(pNewView);
// Set active
pSplitter->GetParentFrame()->SetActiveView(pNewView);
pSplitter->RecalcLayout();
return pOldActiveView;
}
HTH