コード例 #1
0
        private void CreateDeleteButton()
        {
            mDeleteButton = new Button();
            var mDeleteButtonStyle = new ButtonStyle
            {
                Text            = null,
                BackgroundColor = new Selector <Color>(),
                BackgroundImage = new Selector <string>()
                {
                    Normal = DELETE_IMAGE, Selected = DELETE_IMAGE_SELECTED
                }
            };

            mDeleteButton.ApplyStyle(mDeleteButtonStyle);
            mDeleteButton.IsSelectable           = true;
            mDeleteButton.ParentOrigin           = ParentOrigin.BottomRight;
            mDeleteButton.PivotPoint             = PivotPoint.BottomRight;
            mDeleteButton.PositionUsesPivotPoint = true;
            mDeleteButton.DrawMode      = DrawModeType.Overlay2D;
            mDeleteButton.Size          = new Size(50, 50);
            mDeleteButton.LeaveRequired = true;
            mDeleteButton.Hide();
            mDeleteButton.Clicked += (obj, e) =>
            {
                ItemIdCollection removeList = new ItemIdCollection();
                for (uint i = 0; i < mItemView.GetChildCount(); ++i)
                {
                    View child = mItemView.GetChildAt(i);
                    if (child != null)
                    {
                        View tick = child.FindChildByName("Tick");

                        if (tick != null && tick.Visibility)
                        {
                            removeList.Add(mItemView.GetItemId(child));
                        }
                    }
                }

                if (removeList.Count != 0)
                {
                    mItemView.RemoveItems(removeList, 0.5f);
                }
            };
            NUIApplication.GetDefaultWindow().Add(mDeleteButton);
        }