當前位置: 首頁>>代碼示例>>C#>>正文


C# Button.SetBinding方法代碼示例

本文整理匯總了C#中Windows.UI.Xaml.Controls.Button.SetBinding方法的典型用法代碼示例。如果您正苦於以下問題:C# Button.SetBinding方法的具體用法?C# Button.SetBinding怎麽用?C# Button.SetBinding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Windows.UI.Xaml.Controls.Button的用法示例。


在下文中一共展示了Button.SetBinding方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnApplyTemplate

        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _tb = GetTemplateChild("tabButton") as Button;
            

            _tb.Click += _tb_Click;

            var p1 = GetTabListParent(_tb);
            _tb.SetBinding(BorderBrushProperty, new Binding() { Path = new PropertyPath("TabItemBorderColor"), Source = p1 });  
            //_tb.BorderBrush = p1.TabItemBorderColor;
            
        }
開發者ID:liquidboy,項目名稱:X,代碼行數:14,代碼來源:TabListItem.cs

示例2: SetSubMenu

        private void SetSubMenu()
        {
            CircleMenuPanel.Children.Clear();

            foreach (var item in ItemsSource)
            {
                var menuItem = item as CircleMenuItem;
                if (menuItem != null)
                {
                    var btn = new Button();
                    btn.Opacity = 0;
                    var bindTag = new Binding
                    {
                        Path = new PropertyPath("Id"),
                        Source = menuItem,
                        Mode = BindingMode.OneWay
                    };
                    btn.SetBinding(TagProperty, bindTag);//用Tag存儲Id

                    var textBlock = new TextBlock();
                    var bindTitle = new Binding
                    {
                        Path = new PropertyPath("Title"),
                        Source = menuItem,
                        Mode = BindingMode.OneWay
                    };
                    textBlock.SetBinding(TextBlock.TextProperty,bindTitle);

                    btn.Content = textBlock;
                    var binding = new Binding()
                    {
                        Path = new PropertyPath("SubMenuStyle"),
                        RelativeSource = new RelativeSource() { Mode = RelativeSourceMode.TemplatedParent },
                        Source = this
                    };
                    btn.SetBinding(StyleProperty, binding);
                    btn.Click += (s, e) =>
                    {
                        VisualStateManager.GoToState(this, VisualStateCollapsed, false);
                        if (SubClickCommand != null)
                        {
                            var sbtn = s as Button;
                            if (sbtn != null)
                                SubClickCommand(Convert.ToInt32(sbtn.Tag));
                        }
                        SetSubMenu();
                        VisualStateManager.GoToState(this, VisualStateExpanded, false);
                    };

                    CircleMenuPanel.Children.Add(btn);
                }
            }
        }
開發者ID:woniuchn,項目名稱:blog_sample_codes,代碼行數:53,代碼來源:CircleMenu.cs

示例3: OnSourceChanged

        // 依存関係プロパティに値がセットされたときに呼び出されるメソッド
        private static void OnSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RichTextBlock block = new RichTextBlock();
            Tweet tweet = e.NewValue as Tweet;
            Binding detailCommandBinding = new Binding { Path = new PropertyPath("TweetDetailCommand") };

            Binding userDetailCommandBinding = new Binding { Path = new PropertyPath("UserDetailCommand") };

            Binding searchCommandBinding = new Binding() { Path = new PropertyPath("SearchCommand") };

            Binding browseCommandBinding = new Binding() { Path = new PropertyPath("BrowseCommand") };

            Binding previewImageCommandBinding = new Binding() { Path = new PropertyPath("ImagePreviewCommand") };



                SolidColorBrush runForeGround = Application.Current.Resources["ForegroundBrush"] as SolidColorBrush;
                FontFamily tweetFontFamily = Application.Current.Resources["MainFontFamily"] as FontFamily;
                double fontSize = (double)Application.Current.Resources["TimelineFontSize"];
                if (tweet != null)
                {



                    if (tweet.retweeted_status != null)
                    {
                        tweet = tweet.retweeted_status;
                    }

                    
                    Paragraph para = new Paragraph();

                    List<EntitieBase> entities = new List<EntitieBase>();
                    if (tweet.entities != null)
                    {

                        if (tweet.entities.user_mentions != null)
                        {
                            entities.AddRange(tweet.entities.user_mentions);
                        }
                        if (tweet.entities.urls != null)
                        {
                            entities.AddRange(tweet.entities.urls);
                        }
                        if (tweet.entities.hashtags != null)
                        {
                            entities.AddRange(tweet.entities.hashtags);
                        }
                        if (tweet.entities.media != null)
                        {
                            entities.AddRange(tweet.entities.media);
                        }
                    }


                    try
                    {
                        if (tweet.entities != null && entities.Count > 0)
                        {

                            entities.OrderBy(q => q.indices[0]);
                            string back = "";
                            int seek = 0;


                            foreach (EntitieBase entitiy in entities)
                            {

                                int start = entitiy.indices[0];
                                int end = entitiy.indices[1];
                                StringInfo infoText = new StringInfo(tweet.text);
                                back = tweet.text.SubStringByTextElements(end, infoText.LengthInTextElements - end);
                                string front = tweet.text.SubStringByTextElements(seek, start - seek);

                                para.Inlines.Add(new Run { Text = front, Foreground = runForeGround, FontSize = fontSize });
                                var link = new HyperlinkButton();
                                link.Padding = new Thickness(0);
                                // link.Foreground = Application.Current.Resources["AppThemeBrush"] as SolidColorBrush;
                                link.Style = Application.Current.Resources["NeuroniaTimelineHyperlinkButtonStyle"] as Style;
                                link.FontSize = fontSize;

                                var uiContainer = new InlineUIContainer();

                                if (entitiy is UserMention)
                                {
                                    var en = entitiy as UserMention;

                                    link.Content = "@" + en.screen_name;
                                    uiContainer.Child = link;
                                    link.CommandParameter = en.screen_name;
                                    link.SetBinding(HyperlinkButton.CommandProperty, userDetailCommandBinding);
                                }
                                else if (entitiy is TweetUrl)
                                {
                                    var en = entitiy as TweetUrl;
                                    link.Content = en.display_url;
                                    uiContainer.Child = link;
                                    link.CommandParameter = en.url;
                                    link.SetBinding(HyperlinkButton.CommandProperty, browseCommandBinding);
//.........這裏部分代碼省略.........
開發者ID:garicchi,項目名稱:Neuronia,代碼行數:101,代碼來源:TweetRichTextBlock.cs


注:本文中的Windows.UI.Xaml.Controls.Button.SetBinding方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。