当前位置: 首页>>代码示例>>C#>>正文


C# Image.SetBinding方法代码示例

本文整理汇总了C#中Image.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# Image.SetBinding方法的具体用法?C# Image.SetBinding怎么用?C# Image.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Image的用法示例。


在下文中一共展示了Image.SetBinding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HomePageCS

        public HomePageCS()
        {
            BindingContext = this;

            var angleEntry = new Entry { WidthRequest = 50 };
            angleEntry.SetBinding (Entry.TextProperty, "Angle");

            var image = new Image { VerticalOptions = LayoutOptions.CenterAndExpand };
            image.Source = ImageSource.FromFile ("waterfront.jpg");
            image.SetBinding (VisualElement.RotationProperty, "Angle");

            Content = new StackLayout {
                Padding = new Thickness (0, 20, 0, 0),
                Children = {
                    new Label {
                        Text = "Bindable Property Validation Callback Demo",
                        FontAttributes = FontAttributes.Bold,
                        HorizontalOptions = LayoutOptions.Center
                    },
                    new StackLayout {
                        Orientation = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.Center,
                        Children = {
                            new Label { Text = "Rotation angle:" },
                            angleEntry
                        }
                    },
                    image
                }
            };
        }
开发者ID:RickySan65,项目名称:xamarin-forms-samples,代码行数:31,代码来源:HomePageCS.cs

示例2: MenuListTemplate

        public MenuListTemplate()
        {
            List<MenuItem> data = new MenuListData();
            this.ItemsSource = data;
            this.VerticalOptions = LayoutOptions.FillAndExpand;
            this.BackgroundColor = Theme.NavBackgroundColor;
            this.SeparatorColor = Color.Black;
            this.Margin = new Thickness(5);

            var menuDataTemplate = new DataTemplate(() =>
            {
                var pageImage = new Image
                {
                    VerticalOptions = LayoutOptions.Center,
                    HeightRequest = 30,
                    Margin = new Thickness(0, 0, 10, 0)
                };
                var pageLabel = new Label
                {
                    VerticalOptions = LayoutOptions.Center,
                    TextColor = Theme.TextColor,
                    FontSize = 20,
                };

                pageImage.SetBinding(Image.SourceProperty, "IconSource");
                pageLabel.SetBinding(Label.TextProperty, "Name");

                var layout = new StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    VerticalOptions = LayoutOptions.Center,
                    Children =
                    {
                        pageImage,
                        pageLabel
                    }
                };

                var menuFrame = new Frame
                {
                    OutlineColor = Theme.NavBackgroundColor,
                    BackgroundColor = Theme.NavBackgroundColor,
                    VerticalOptions = LayoutOptions.Center,
                    Padding = new Thickness(10),
                    Content = layout
                };

                return new ViewCell { View = menuFrame };
            });



            var cell = new DataTemplate(typeof(ViewCell));
            cell.SetBinding(TextCell.TextProperty, "Name");
            cell.SetValue(TextCell.TextColorProperty, Color.FromHex("2f4f4f"));


            this.ItemTemplate = menuDataTemplate;
            this.SelectedItem = data[0];
        }
开发者ID:threezool,项目名称:LaunchPal,代码行数:60,代码来源:MenuListTemplate.cs

示例3: CustomCell

            public CustomCell()
            {
                //instantiate each of our views
                var image = new Image();
                StackLayout cellWrapper = new StackLayout();
                StackLayout horizontalLayout = new StackLayout();
                Label left = new Label();
                Label right = new Label();

                //set bindings
                left.SetBinding(Label.TextProperty, "name");
                right.SetBinding(Label.TextProperty, "description");
                image.SetBinding(Image.SourceProperty, "profileIcon");

                //Set properties for desired design
                cellWrapper.BackgroundColor = Color.FromHex("#eee");
                horizontalLayout.Orientation = StackOrientation.Horizontal;
                right.HorizontalOptions = LayoutOptions.EndAndExpand;
                left.TextColor = Color.FromHex("#f35e20");
                right.TextColor = Color.FromHex("503026");

                //add views to the view hierarchy
                horizontalLayout.Children.Add(image);
                horizontalLayout.Children.Add(left);
                horizontalLayout.Children.Add(right);
                cellWrapper.Children.Add(horizontalLayout);
                View = cellWrapper;
            }
开发者ID:sabeersulaiman,项目名称:OAuthTwoDemo.XForms,代码行数:28,代码来源:ProfilePage.cs

示例4: CommentCell

        public CommentCell()
        {
            Label lblTitle = new Label();
            lblTitle.SetBinding(Label.TextProperty, "Text");
            lblTitle.LineBreakMode = LineBreakMode.WordWrap;

            Label lblDate = new Label();
            lblDate.SetBinding(Label.TextProperty, "CreatedAt");

            var childLayout = new StackLayout
            {
                Padding = new Thickness(5),
                Orientation = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Children = { lblTitle, lblDate }
            };
            

            Image image = new Image();
            image.SetBinding(Image.SourceProperty, "AuthorAvatar");
            image.HeightRequest = 50;
            image.WidthRequest = 50;
			image.Aspect = Aspect.AspectFit;

            var layout = new StackLayout
            {
				Padding = new Thickness(5),
                Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Children = { image, childLayout }
            };
            View = layout;

        }
开发者ID:Ontropix,项目名称:onliner-reader,代码行数:34,代码来源:CommentCell.cs

示例5: SelectCell

        public SelectCell()
        {
            CellText = new Label()
            {
                VerticalOptions = LayoutOptions.CenterAndExpand,
            };
            CellText.SetBinding(Label.TextProperty, "Text");

            CheckImage = new Image()
            {
                HorizontalOptions = LayoutOptions.EndAndExpand,
                Margin = imgThick,
                IsVisible = false,
            };

            CheckImage.SetBinding(VisualElement.IsVisibleProperty, "IsSelected");
            CheckImage.Source = checkImg;

            var layout = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal,
                Spacing = 8,
                Padding = stkThick,
            };
            layout.Children.Add(CellText);
            layout.Children.Add(CheckImage);

            View = layout;
        }
开发者ID:XZiar,项目名称:WordsLinks,代码行数:29,代码来源:CellEx.cs

示例6: ProductCell

        public ProductCell()
        {
            // instantiate each of our views
            var image = new Image();
            var cellLayout = new StackLayout();
            var detailsLayout = new StackLayout();
            var nameLabel = new Label();
            var descriptionLabel = new Label();
            var priceLabel = new Label();

            // set bindings
            image.SetBinding(Image.SourceProperty, new Binding("ImageSource", converter: new PathToImageSourceConverter()));
            nameLabel.SetBinding(Label.TextProperty, "Name");
            descriptionLabel.SetBinding(Label.TextProperty, "Description");
            priceLabel.SetBinding(Label.TextProperty, new Binding("Price", stringFormat: "Price: ${0:0.00}"));

            // set properties for desired design
            image.HeightRequest = 70;
            image.WidthRequest = 70;
            descriptionLabel.FontSize =  Device.GetNamedSize(NamedSize.Small, typeof (Label));
            descriptionLabel.TextColor = Color.Gray;
            priceLabel.TextColor = Color.Red;
            cellLayout.Padding = new Thickness(5, 5, 5, 5);
            cellLayout.Orientation = StackOrientation.Horizontal;
            detailsLayout.Padding = new Thickness(5, 0, 0, 0);

            // add views to the view hierarchy
            cellLayout.Children.Add(image);
            cellLayout.Children.Add(detailsLayout);
            detailsLayout.Children.Add(nameLabel);
            detailsLayout.Children.Add(descriptionLabel);
            detailsLayout.Children.Add(priceLabel);
            View = cellLayout;
        }
开发者ID:maxklippa,项目名称:eCommerce,代码行数:34,代码来源:ProductCell.cs

示例7: FancyListCell

        public FancyListCell()
        {
            var image = new Image
              {
            HorizontalOptions = LayoutOptions.Start
              };
              image.SetBinding(Image.SourceProperty, new Binding("Icon"));
              image.WidthRequest = image.HeightRequest = 50;

              var nameLabel = new Label
              {
            HorizontalOptions = LayoutOptions.FillAndExpand,
            VerticalOptions = LayoutOptions.Center,
            FontSize = 26,
            TextColor = Color.Red
               // BackgroundColor = Color.FromRgba(0,0,0,0.5f)
              };
              nameLabel.SetBinding(Label.TextProperty, "Title");

              var viewLayout = new StackLayout()
              {
            Orientation = StackOrientation.Horizontal,
            Spacing = 10,
            Padding = 15,
            Children = { image, nameLabel }
              };
              View = viewLayout;
        }
开发者ID:RobertoOFonseca,项目名称:MySafety,代码行数:28,代码来源:FancyListCell.cs

示例8: OnApplyTemplate

 public override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     btnNormalImage = this.GetTemplateChild("btnNormalImage") as Image;
     if (btnNormalImage != null)
         btnNormalImage.SetBinding(Image.SourceProperty, this, "ImageSource");
     btnPressedImage = this.GetTemplateChild("btnPressedImage") as Image;
     if (btnPressedImage != null)
         btnPressedImage.SetBinding(Image.SourceProperty, this, "PressedImageSource");
 }
开发者ID:saykorz,项目名称:LunarBase,代码行数:10,代码来源:ImageButton.cs

示例9: ListImageCell

        public ListImageCell()
        {
            Image icon = new Image {
                Aspect = Aspect.AspectFill,
                WidthRequest = 25,
                HeightRequest = 25,
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };
            icon.SetBinding (Image.SourceProperty, HomeViewModel.TitlePropertyName, BindingMode.Default, new MenuIconConverter ());

            Label LabelName = new Label {
                Style = Styles.DefaultCellText,
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };
            LabelName.SetBinding (Label.TextProperty, HomeViewModel.TitlePropertyName, BindingMode.TwoWay);

            //            Image badge = new Image
            //            {
            //                Source = Images.HollyDayTicket,
            //                Aspect = Aspect.AspectFill,
            //                WidthRequest = 25,
            //                HeightRequest = 25,
            //                HorizontalOptions = LayoutOptions.EndAndExpand,
            //                VerticalOptions = LayoutOptions.CenterAndExpand
            //            };

            StackLayout stack = new StackLayout {
                Padding = new Thickness (15, 0, 0, 0), Spacing = 20,
                Orientation = StackOrientation.Horizontal,
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children = { icon, LabelName }
            };

            var absoluteLayout = new AbsoluteLayout ();
            var background = new Image {
                Style = Styles.CellBackground
            };

            absoluteLayout.Children.Add (background, new Rectangle (0, 0, 1, 1), AbsoluteLayoutFlags.All);
            absoluteLayout.Children.Add (stack, new Rectangle (0, 0, 1, 1), AbsoluteLayoutFlags.All);

            View = absoluteLayout;
        }
开发者ID:RobertoOFonseca,项目名称:MySafety,代码行数:46,代码来源:ListImageCell.cs

示例10: AddButton

 public void AddButton(string btnId, string iconId, Action onClick, string toolTip)
 {
     if (_buttons.ContainsKey(btnId))
     {
         if (iconId != null)
         {
             BindingOperations.ClearBinding(((Image)_buttons[btnId].Content), Image.SourceProperty);
             var path = String.Format("IconManagerInstance[{0}].ImageSource", iconId);
             ((Image)_buttons[btnId].Content).SetBinding(Image.SourceProperty, new Binding
             {
                 ElementName = "Plugins",
                 Path = new PropertyPath(path)
             });
         }
         if (toolTip != null)
             _buttons[btnId].ToolTip = toolTip;
         return;
     }
     MainGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(38, GridUnitType.Pixel) });
     var im = new Image();
     var bindingPath = String.Format("IconManagerInstance[{0}].ImageSource", iconId);
     im.SetBinding(Image.SourceProperty, new Binding
     {
         ElementName = "Plugins",
         Path = new PropertyPath(bindingPath)
     });
     var bt = new Button
     {
         BorderThickness = new Thickness(0),
         ToolTip = toolTip,
         Content = im,
         Template = (ControlTemplate)FindResource("BorderlessButtonControlTemplate")
     };
     bt.Click += (sender, args) =>
     {
         DoFocusChange();
         onClick();
     };
     Grid.SetRow(bt, MainGrid.RowDefinitions.Count - 1);
     _buttons.Add(btnId, bt);
     MainGrid.Children.Add(bt);
     Height = MainGrid.RowDefinitions.Count * 38 + 16;
     UpdatePosition();
 }
开发者ID:OronDF343,项目名称:Sky-Jukebox,代码行数:44,代码来源:PluginsWidget.xaml.cs

示例11: LoadingPage

        public LoadingPage(RootPage rootPage)
        {
            _rootPage = rootPage;
            NavigationPage.SetHasNavigationBar (this, false);

            //TODO : Inject ForecastService

            _viewModel = new LoadingViewModel (Navigation, new ForecastService (new OpenWeatherMapService (new HttpClient ())), rootPage);
            BindingContext = _viewModel;

            var statusMessageLabel = new LargeLabel {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.Center,
                TextColor = Color.White,
            };

            statusMessageLabel.SetBinding<LoadingViewModel> (Label.TextProperty, vm => vm.StatusMessage);

            var stackLayout = new StackLayout {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.Center,
                Spacing = 10
            };

            var loadingImage = new Image ();

            loadingImage.SetBinding<LoadingViewModel> (Image.SourceProperty, vm => vm.LoadingImage);

            var refreshButton = new Button{ Text = "Refresh", HorizontalOptions = LayoutOptions.Center };

            refreshButton.SetBinding<LoadingViewModel> (Button.CommandProperty, vm => vm.GetForecastCommand);
            refreshButton.SetBinding<LoadingViewModel> (VisualElement.IsVisibleProperty, vm => vm.IsRefreshButtonVisible);

            var activityIndicator = new ActivityIndicator{ IsRunning = true };

            activityIndicator.SetBinding<LoadingViewModel> (VisualElement.IsVisibleProperty, vm => vm.IsActivityIndicatorVisible);

            stackLayout.Children.Add (loadingImage);
            stackLayout.Children.Add (statusMessageLabel);
            stackLayout.Children.Add (activityIndicator);
            stackLayout.Children.Add (refreshButton);

            Content = stackLayout;
        }
开发者ID:vmoll,项目名称:ShouldIWashMyCar,代码行数:44,代码来源:LoadingPage.cs

示例12: ViewPage

        public ViewPage()
        {
            if (Device.OS == TargetPlatform.iOS)
                Padding = new Thickness(0, 20, 0, 0);

            // let's get a page title from the binding context created when the carousel rotates
            this.SetBinding(ContentPage.TitleProperty, "Title");

            // create the image and bind to the ImageName property
            var imgView = new Image();
            imgView.SetBinding(Image.SourceProperty, "ImageName");

            Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Children =
                {
                    imgView
                }
            };
        }
开发者ID:nodoid,项目名称:xamforms-layouts,代码行数:22,代码来源:ViewPage.cs

示例13: LatestThinkingCell

        public LatestThinkingCell()
        {
            var image = new Image ();
            StackLayout cellWrapper = new StackLayout ();
            StackLayout horizontalLayout = new StackLayout ();
            Label left = new Label ();

            //set bindings
            left.SetBinding (Label.TextProperty, "Title");
            image.SetBinding (Image.SourceProperty, "Image");

            //Set properties for desired design
            cellWrapper.BackgroundColor = Color.White;
            horizontalLayout.Orientation = StackOrientation.Horizontal;
            horizontalLayout.Padding = new Thickness (10,10,10,10);
            left.TextColor = Color.FromRgb(0, 112, 116);

            //add views to the view hierarchy

            horizontalLayout.Children.Add (left);
            horizontalLayout.Children.Add (image);
            cellWrapper.Children.Add (horizontalLayout);
            View = cellWrapper;
        }
开发者ID:henrytranvan,项目名称:HSFFinance,代码行数:24,代码来源:LatestThinkingCell.cs

示例14: FeedCell

        public FeedCell()
        {

            Label lblTitle = new Label();
            lblTitle.SetBinding(Label.TextProperty, "Title");
            lblTitle.LineBreakMode = LineBreakMode.WordWrap;
			lblTitle.Font = Font.SystemFontOfSize (14);

            Label lblDate = new Label();
            lblDate.SetBinding(Label.TextProperty, "PublishDate");
			lblDate.Font = Font.SystemFontOfSize (12);

            var childLayout = new StackLayout
            {
                Padding = new Thickness(5),
                Orientation = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Children = { lblTitle, lblDate }
            };
				
            Image image = new Image();
            image.SetBinding(Image.SourceProperty, "Image");
            image.HeightRequest = 50;
            image.WidthRequest = 50;
			image.Aspect = Aspect.AspectFill;

            var layout = new StackLayout
            {
                Padding = new Thickness(5),
                Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Children = { image, childLayout }
            };

            View = layout;
        }
开发者ID:Ontropix,项目名称:onliner-reader,代码行数:36,代码来源:FeedCell.cs

示例15: VetCell

            public VetCell()
            {
                var vetProfileImage = new CircleImage
                {
                    BorderColor = App.BrandColor,
                    BorderThickness = 2,
                    HeightRequest = 50,
                    WidthRequest = 50,
                    Aspect = Aspect.AspectFill,
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions = LayoutOptions.Center,
                };
                vetProfileImage.SetBinding(Image.SourceProperty, "ImageSource");

                var nameLabel = new Label()
                {
                    FontFamily = "HelveticaNeue-Medium",
                    FontSize = 18,
                    TextColor = Color.Black
                };
                nameLabel.SetBinding(Label.TextProperty, "Name");

                var distanceLabel = new Label()
                {
                    FontAttributes = FontAttributes.Bold,
                    FontSize = 12,
                    TextColor = Color.FromHex("#666")
                };
                distanceLabel.SetBinding(
                                Label.TextProperty, new Binding(
                                        "Distance",
                                        stringFormat: "{0} Miles Away")
                        );

                // Online image and label
                var onlineImage = new Image()
                {
                    Source = "online.png",
                    HeightRequest = 8,
                    WidthRequest = 8
                };
                onlineImage.SetBinding(Image.IsVisibleProperty, "ShouldShowAsOnline");
                var onLineLabel = new Label()
                {
                    Text = "Online",
                    TextColor = App.BrandColor,
                    FontSize = 12,
                };
                onLineLabel.SetBinding(Label.IsVisibleProperty, "ShouldShowAsOnline");

                // Offline image and label
                var offlineImage = new Image()
                {
                    Source = "offline.png",
                    HeightRequest = 8,
                    WidthRequest = 8
                };
                offlineImage.SetBinding(Image.IsVisibleProperty, "ShouldShowAsOffline");
                var offLineLabel = new Label()
                {
                    Text = "5 hours ago",
                    TextColor = Color.FromHex("#ddd"),
                    FontSize = 12,
                };
                offLineLabel.SetBinding(Label.IsVisibleProperty, "ShouldShowAsOffline");

                // Vet rating label and star image
                var starLabel = new Label()
                {
                    FontSize = 12,
                    TextColor = Color.Gray
                };
                starLabel.SetBinding(Label.TextProperty, "Stars");

                var starImage = new Image()
                {
                    Source = "star.png",
                    HeightRequest = 12,
                    WidthRequest = 12
                };

                var ratingStack = new StackLayout()
                {
                    Spacing = 3,
                    Orientation = StackOrientation.Horizontal,
                    Children = { starImage, starLabel }
                };

                var statusLayout = new StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    Children = { 
                                distanceLabel, 
                                onlineImage, 
                                onLineLabel, 
                                offlineImage, 
                                offLineLabel 
                        }
                };

//.........这里部分代码省略.........
开发者ID:sabeersulaiman,项目名称:OAuthTwoDemo.XForms,代码行数:101,代码来源:ProfilePage.cs


注:本文中的Image.SetBinding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。