Exemple #1
0
        public MenuPage(MenuViewModel.EnumAmbiente ambiente)
        {
            this.BindingContext = new MenuViewModel(ambiente);

            this.SetBinding(ContentPage.TitleProperty, "Titolo");

            Button buttonTest = Utility.UserInterface.CreateButton(AppResources.Test);

            buttonTest.SetBinding(Button.CommandProperty, "TestCommand");

            Content = new StackLayout
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          =
                {
                    buttonTest
                }
            };

            InvokeCommandAction icaOnAppearing = new InvokeCommandAction();

            icaOnAppearing.SetBinding(InvokeCommandAction.CommandProperty, "OnAppearingCommand");
            EventHandlerBehavior ehbOnAppearing = new EventHandlerBehavior()
            {
                EventName = "Appearing"
            };

            ehbOnAppearing.Actions.Add(icaOnAppearing);

            InvokeCommandAction icaOnDisappearing = new InvokeCommandAction();

            icaOnDisappearing.SetBinding(InvokeCommandAction.CommandProperty, "OnDisappearingCommand");
            EventHandlerBehavior ehbOnDisappearing = new EventHandlerBehavior()
            {
                EventName = "Disappearing"
            };

            ehbOnDisappearing.Actions.Add(icaOnDisappearing);

            this.Behaviors.Add(ehbOnAppearing);
            this.Behaviors.Add(ehbOnDisappearing);
        }
Exemple #2
0
        public MainPage()
        {
            _vm = new MainPageViewModel();
            this.BindingContext = _vm;


            Button buttonStart = new Button {
                Text = "START SCANNING BEACONS"
            };

            buttonStart.SetBinding(Button.CommandProperty, "StartRangingCommand");
            buttonStart.SetBinding(Button.TextProperty, new Binding("IsStartedRanging", converter: new IsStartedRangingToTextConverter()));
            Label labelInfo = new Label()
            {
                HorizontalOptions = LayoutOptions.Center, Text = "Beacons oredered by RSSI"
            };

            Button buttonTransmit = new Button {
                Text = "START BEACON"
            };

            buttonTransmit.SetBinding(Button.CommandProperty, "StartTransmitting");
            buttonTransmit.SetBinding(Button.TextProperty, new Binding("IsTransmitting", converter: new IsTransmittingToTextConverter()));


            StackLayout slHeader = new StackLayout()
            {
                Children = { buttonTransmit, buttonStart, labelInfo, }
            };

            ListView lv = new ListView {
                HasUnevenRows = true, SeparatorColor = Color.Black, SeparatorVisibility = SeparatorVisibility.Default, Header = slHeader
            };

            lv.SetBinding(ListView.ItemsSourceProperty, "ReceivedBeacons");
            lv.SetBinding(ListView.ItemTemplateProperty, "ViewCellBeaconTemplate");

            StackLayout sl = new StackLayout
            {
                Children = { lv }
            };

            CompressedLayout.SetIsHeadless(sl, true);

            Content = sl;

            InvokeCommandAction icaOnAppearing = new InvokeCommandAction();

            icaOnAppearing.SetBinding(InvokeCommandAction.CommandProperty, "OnAppearingCommand");
            EventHandlerBehavior ehbOnAppearing = new EventHandlerBehavior()
            {
                EventName = "Appearing"
            };

            ehbOnAppearing.Actions.Add(icaOnAppearing);

            InvokeCommandAction icaOnDisappearing = new InvokeCommandAction();

            icaOnDisappearing.SetBinding(InvokeCommandAction.CommandProperty, "OnDisappearingCommand");
            EventHandlerBehavior ehbOnDisappearing = new EventHandlerBehavior()
            {
                EventName = "Disappearing"
            };

            ehbOnDisappearing.Actions.Add(icaOnDisappearing);

            this.Behaviors.Add(ehbOnAppearing);
            this.Behaviors.Add(ehbOnDisappearing);
        }