本文整理汇总了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;
}
示例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);
}
}
}
示例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);
//.........这里部分代码省略.........