本文整理汇总了C#中TextBlock.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# TextBlock.SetBinding方法的具体用法?C# TextBlock.SetBinding怎么用?C# TextBlock.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextBlock
的用法示例。
在下文中一共展示了TextBlock.SetBinding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: r_11_dtMethod
private static UIElement r_11_dtMethod(UIElement parent)
{
// e_69 element
Border e_69 = new Border();
e_69.Parent = parent;
e_69.Name = "e_69";
e_69.Background = new SolidColorBrush(new ColorW(0, 0, 255, 255));
// e_70 element
StackPanel e_70 = new StackPanel();
e_69.Child = e_70;
e_70.Name = "e_70";
// e_71 element
TextBlock e_71 = new TextBlock();
e_70.Children.Add(e_71);
e_71.Name = "e_71";
e_71.HorizontalAlignment = HorizontalAlignment.Center;
e_71.VerticalAlignment = VerticalAlignment.Center;
Binding binding_e_71_Text = new Binding("TextData");
e_71.SetBinding(TextBlock.TextProperty, binding_e_71_Text);
// e_72 element
Button e_72 = new Button();
e_70.Children.Add(e_72);
e_72.Name = "e_72";
e_72.Content = "Hide Window";
Binding binding_e_72_Command = new Binding("HideCommand");
e_72.SetBinding(Button.CommandProperty, binding_e_72_Command);
return e_69;
}
示例2: e_28_Col3_ct_dtMethod
private static UIElement e_28_Col3_ct_dtMethod(UIElement parent)
{
// e_30 element
StackPanel e_30 = new StackPanel();
e_30.Parent = parent;
e_30.Name = "e_30";
// e_31 element
TextBlock e_31 = new TextBlock();
e_30.Children.Add(e_31);
e_31.Name = "e_31";
Binding binding_e_31_Text = new Binding("Text");
e_31.SetBinding(TextBlock.TextProperty, binding_e_31_Text);
// e_32 element
StackPanel e_32 = new StackPanel();
e_30.Children.Add(e_32);
e_32.Name = "e_32";
e_32.Orientation = Orientation.Horizontal;
// e_33 element
TextBlock e_33 = new TextBlock();
e_32.Children.Add(e_33);
e_33.Name = "e_33";
Binding binding_e_33_Text = new Binding("Boolean");
e_33.SetBinding(TextBlock.TextProperty, binding_e_33_Text);
// e_34 element
TextBlock e_34 = new TextBlock();
e_32.Children.Add(e_34);
e_34.Name = "e_34";
Binding binding_e_34_Text = new Binding("Number");
e_34.SetBinding(TextBlock.TextProperty, binding_e_34_Text);
return e_30;
}
示例3: e_23_Col3_ct_dtMethod
private static UIElement e_23_Col3_ct_dtMethod(UIElement parent)
{
// e_25 element
StackPanel e_25 = new StackPanel();
e_25.Parent = parent;
e_25.Name = "e_25";
// e_26 element
TextBlock e_26 = new TextBlock();
e_25.Children.Add(e_26);
e_26.Name = "e_26";
Binding binding_e_26_Text = new Binding("Text");
e_26.SetBinding(TextBlock.TextProperty, binding_e_26_Text);
// e_27 element
StackPanel e_27 = new StackPanel();
e_25.Children.Add(e_27);
e_27.Name = "e_27";
e_27.Orientation = Orientation.Horizontal;
// e_28 element
TextBlock e_28 = new TextBlock();
e_27.Children.Add(e_28);
e_28.Name = "e_28";
Binding binding_e_28_Text = new Binding("Boolean");
e_28.SetBinding(TextBlock.TextProperty, binding_e_28_Text);
// e_29 element
TextBlock e_29 = new TextBlock();
e_27.Children.Add(e_29);
e_29.Name = "e_29";
Binding binding_e_29_Text = new Binding("Number");
e_29.SetBinding(TextBlock.TextProperty, binding_e_29_Text);
return e_25;
}
示例4: combo_dtMethod
private static UIElement combo_dtMethod(UIElement parent)
{
// e_4 element
TextBlock e_4 = new TextBlock();
e_4.Parent = parent;
e_4.Name = "e_4";
e_4.Margin = new Thickness(2F, 2F, 2F, 2F);
e_4.HorizontalAlignment = HorizontalAlignment.Center;
Binding binding_e_4_Text = new Binding("Name");
e_4.SetBinding(TextBlock.TextProperty, binding_e_4_Text);
return e_4;
}
示例5: AccountItemViewer
public AccountItemViewer()
{
this.InitializeComponent();
TiltEffect.SetIsTiltEnabled(this, true);
this.accountItemViewModel = ViewModelLocator.AccountItemViewModel;
base.Loaded += new RoutedEventHandler(this.AccountItemViewer_Loaded);
this.NeedReloadData = true;
this.accountItemViewerViewModel = new AccountItemViewerViewModel();
this.RelatedItemsPivot.DataContext = this;
var textTitle = new TextBlock();
textTitle.SetBinding(TextBlock.TextProperty, new System.Windows.Data.Binding("CreateDateInfo"));
textTitle.Tap += textTitle_Tap;
MainPivot.Title = textTitle;
}
示例6: VersionsChanged
protected void VersionsChanged(object sender, EventArgs e)
{
if (versions.Count == 0)
return;
for (int i = 0; i < _Versions.Count; i++)
{
ListViewItem item = _Versions[i];
Mod mod = ((ModVersionViewModel)item.DataContext).mod;
if (!versions.Values.Contains(mod))
{
_Versions.RemoveAt(i);
i--;
}
}
List<int> versionKeys = versions.Keys.ToList();
versionKeys.Sort();
versionKeys.Reverse();
ListViewItem[] old = _Versions.ToArray();
_Versions = new ObservableCollection<ListViewItem>();
foreach (int n in versionKeys)
{
Mod mod = versions[n];
bool add = true;
/*foreach (ListViewItem item in _Versions)
{
if (item.DataContext == mod)
{
add = false;
break;
}
}*/
if (add)
{
ListViewItem newItem = new ListViewItem();
StackPanel panel = new StackPanel();
panel.Orientation = Orientation.Vertical;
newItem.DataContext = new ModVersionViewModel(mod);
TextBlock label = new TextBlock();
label.SetBinding(TextBlock.TextProperty, "Version");
StackPanel panel2 = new StackPanel();
panel2.Orientation = Orientation.Horizontal;
TextBlock compatibleLabel = new TextBlock();
compatibleLabel.SetResourceReference(TextBlock.TextProperty, "Lang.Mods.Labels.Compatible");
compatibleLabel.FontSize = 14;
compatibleLabel.Margin = new Thickness(0, 0, 5, 0);
TextBlock label2 = new TextBlock();
label2.SetBinding(TextBlock.TextProperty, "Compatible");
label2.FontSize = 14;
panel2.Children.Add(compatibleLabel);
panel2.Children.Add(label2);
panel.Children.Add(label);
panel.Children.Add(panel2);
newItem.Content = panel;
_Versions.Add(newItem);
}
}
OnPropertyChanged("Versions");
if (_Initialized)
{
DontSaveVersion = true;
int versionToPrefer = Configuration.GetInt("Mods." + versions[versions.Keys.ToArray()[0]].Game.GameConfiguration.ID + "." + versions[versions.Keys.ToArray()[0]].ID + ".Version");
bool found = false;
foreach (ListViewItem item in _Versions)
{
Mod mod = ((ModVersionViewModel)item.DataContext).mod;
int build = Mod.Header.ParseModVersion(mod.header.GetVersion());
if (build == versionToPrefer)
{
SelectedVersion = item;
found = true;
}
}
if (!found)
{
if (_Versions.Count > 0)
SelectedVersion = _Versions[0];
else
SelectedVersion = null;
}
DontSaveVersion = false;
OnPropertyChanged("SelectedVersion");
OnPropertyChanged("Name");
OnPropertyChanged("Description");
OnPropertyChanged("Version");
}
}
示例7: r_6_dtMethod
private static UIElement r_6_dtMethod(UIElement parent)
{
// e_66 element
TextBlock e_66 = new TextBlock();
e_66.Parent = parent;
e_66.Name = "e_66";
e_66.Margin = new Thickness(2F, 2F, 2F, 2F);
Binding binding_e_66_Text = new Binding("Name");
e_66.SetBinding(TextBlock.TextProperty, binding_e_66_Text);
return e_66;
}
示例8: r_5_dtMethod
private static UIElement r_5_dtMethod(UIElement parent)
{
// e_8 element
TextBlock e_8 = new TextBlock();
e_8.Parent = parent;
e_8.Name = "e_8";
e_8.Margin = new Thickness(2F, 2F, 2F, 2F);
Binding binding_e_8_Text = new Binding("Name");
binding_e_8_Text.UseGeneratedBindings = true;
e_8.SetBinding(TextBlock.TextProperty, binding_e_8_Text);
return e_8;
}
示例9: InitPopup
private void InitPopup()
{
popup = new Popup();
popup.Opened += popup_Opened;
Binding backgroundBinding = new Binding("Background");
backgroundBinding.Source = this;
Binding foregroundBinding = new Binding("Foreground");
foregroundBinding.Source = this;
Grid border = new Grid();
border.Background = new SolidColorBrush(Color.FromArgb(200, 0, 0, 0));
border.Width = Application.Current.Host.Content.ActualWidth;
border.Height = Application.Current.Host.Content.ActualHeight;
Grid container = new Grid();
CompositeTransform transform = new CompositeTransform()
{
TranslateY = -Application.Current.Host.Content.ActualHeight
};
container.RenderTransform = transform;
container.VerticalAlignment = System.Windows.VerticalAlignment.Top;
container.SetBinding(Grid.BackgroundProperty, backgroundBinding);
#region init grid rows
RowDefinition row1 = new RowDefinition()
{
Height = GridLength.Auto
};
container.RowDefinitions.Add(row1);
RowDefinition row2 = new RowDefinition()
{
Height = GridLength.Auto
};
container.RowDefinitions.Add(row2);
RowDefinition row3 = new RowDefinition()
{
Height = GridLength.Auto
};
container.RowDefinitions.Add(row3);
#endregion
TextBlock title = new TextBlock()
{
Margin = new Thickness(12),
FontSize = 30,
FontWeight = FontWeights.Black
};
Binding titleBinding = new Binding("Title");
titleBinding.Source = this;
title.SetBinding(TextBlock.TextProperty, titleBinding);
title.SetBinding(TextBlock.ForegroundProperty, foregroundBinding);
container.Children.Add(title);
TextBlock content = new TextBlock()
{
Margin = new Thickness(12),
FontSize = 26,
FontWeight = FontWeights.Medium
};
Binding contentBinding = new Binding("Content");
contentBinding.Source = this;
content.SetBinding(TextBlock.TextProperty, contentBinding);
content.SetBinding(TextBlock.ForegroundProperty, foregroundBinding);
content.SetValue(Grid.RowProperty, 1);
container.Children.Add(content);
switch (MessageBoxButtons)
{
case MessageBoxButton.OK:
{
Button btn = new Button()
{
Content = "OK",
Margin = new Thickness(0, 0, 0, 10)
};
btn.Click += (s, args) =>
{
var handler = OKClick;
if (null != handler)
{
handler(this, new RoutedEventArgs());
}
GetCloseAnimation();
};
btn.SetValue(Grid.RowProperty, 2);
container.Children.Add(btn);
}
break;
//.........这里部分代码省略.........
示例10: CreateIntervalTimeSliderPanel
private StackPanel CreateIntervalTimeSliderPanel()
{
var child = CreatePanel(Resources.AppResources.IntervalTime);
Debug.WriteLine("create panel: " + Resources.AppResources.IntervalTime);
var slider = CreateSlider(5, 30);
slider.Value = ApplicationSettings.GetInstance().IntervalTime;
slider.ValueChanged += (sender, e) =>
{
ApplicationSettings.GetInstance().IntervalTime = (int)e.NewValue;
};
var hPanel = new StackPanel
{
Orientation = System.Windows.Controls.Orientation.Horizontal,
HorizontalAlignment = HorizontalAlignment.Stretch,
VerticalAlignment = VerticalAlignment.Center
};
var selectedbind = new Binding()
{
Source = ApplicationSettings.GetInstance(),
Path = new PropertyPath("IntervalTime"),
Mode = BindingMode.TwoWay
};
var indicator = new TextBlock
{
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = System.Windows.VerticalAlignment.Top,
Style = Application.Current.Resources["PhoneTextNormalStyle"] as Style,
Margin = new Thickness(10, 15, 0, 0),
MinWidth = 25
};
indicator.SetBinding(TextBlock.TextProperty, selectedbind);
slider.SetBinding(Slider.ValueProperty, selectedbind);
hPanel.Children.Add(indicator);
hPanel.Children.Add(slider);
child.Children.Add(hPanel);
return child;
}
示例11: Get_TabControl_Items
private static System.Collections.ObjectModel.ObservableCollection<object> Get_TabControl_Items()
{
System.Collections.ObjectModel.ObservableCollection<object> items = new System.Collections.ObjectModel.ObservableCollection<object>();
// e_3 element
TabItem e_3 = new TabItem();
e_3.Name = "e_3";
e_3.HorizontalContentAlignment = HorizontalAlignment.Stretch;
e_3.Header = "Controls";
// e_4 element
Grid e_4 = new Grid();
e_3.Content = e_4;
e_4.Name = "e_4";
RowDefinition row_e_4_0 = new RowDefinition();
row_e_4_0.Height = new GridLength(1F, GridUnitType.Auto);
e_4.RowDefinitions.Add(row_e_4_0);
RowDefinition row_e_4_1 = new RowDefinition();
row_e_4_1.Height = new GridLength(1F, GridUnitType.Auto);
e_4.RowDefinitions.Add(row_e_4_1);
RowDefinition row_e_4_2 = new RowDefinition();
row_e_4_2.Height = new GridLength(1F, GridUnitType.Auto);
e_4.RowDefinitions.Add(row_e_4_2);
RowDefinition row_e_4_3 = new RowDefinition();
row_e_4_3.Height = new GridLength(1F, GridUnitType.Auto);
e_4.RowDefinitions.Add(row_e_4_3);
RowDefinition row_e_4_4 = new RowDefinition();
row_e_4_4.Height = new GridLength(1F, GridUnitType.Auto);
e_4.RowDefinitions.Add(row_e_4_4);
RowDefinition row_e_4_5 = new RowDefinition();
row_e_4_5.Height = new GridLength(1F, GridUnitType.Auto);
e_4.RowDefinitions.Add(row_e_4_5);
RowDefinition row_e_4_6 = new RowDefinition();
row_e_4_6.Height = new GridLength(1F, GridUnitType.Auto);
e_4.RowDefinitions.Add(row_e_4_6);
RowDefinition row_e_4_7 = new RowDefinition();
row_e_4_7.Height = new GridLength(1F, GridUnitType.Auto);
e_4.RowDefinitions.Add(row_e_4_7);
RowDefinition row_e_4_8 = new RowDefinition();
row_e_4_8.Height = new GridLength(1F, GridUnitType.Auto);
e_4.RowDefinitions.Add(row_e_4_8);
RowDefinition row_e_4_9 = new RowDefinition();
row_e_4_9.Height = new GridLength(1F, GridUnitType.Auto);
e_4.RowDefinitions.Add(row_e_4_9);
ColumnDefinition col_e_4_0 = new ColumnDefinition();
col_e_4_0.Width = new GridLength(1F, GridUnitType.Auto);
e_4.ColumnDefinitions.Add(col_e_4_0);
ColumnDefinition col_e_4_1 = new ColumnDefinition();
e_4.ColumnDefinitions.Add(col_e_4_1);
// e_5 element
TextBlock e_5 = new TextBlock();
e_4.Children.Add(e_5);
e_5.Name = "e_5";
e_5.VerticalAlignment = VerticalAlignment.Center;
e_5.Text = "Button";
// button1 element
Button button1 = new Button();
e_4.Children.Add(button1);
button1.Name = "button1";
button1.Height = 30F;
button1.Width = 200F;
button1.Margin = new Thickness(5F, 5F, 5F, 5F);
button1.HorizontalAlignment = HorizontalAlignment.Left;
button1.TabIndex = 1;
button1.Content = "Button 1";
button1.CommandParameter = "Click Button 1";
Grid.SetColumn(button1, 1);
Grid.SetRow(button1, 0);
Binding binding_button1_Command = new Binding("ButtonCommand");
button1.SetBinding(Button.CommandProperty, binding_button1_Command);
// button2 element
Button button2 = new Button();
e_4.Children.Add(button2);
button2.Name = "button2";
button2.Height = 30F;
button2.Width = 200F;
button2.Margin = new Thickness(5F, 5F, 5F, 5F);
button2.HorizontalAlignment = HorizontalAlignment.Left;
button2.TabIndex = 2;
button2.Content = "Button 2";
button2.CommandParameter = "Click Button 2";
Grid.SetColumn(button2, 1);
Grid.SetRow(button2, 1);
Binding binding_button2_IsEnabled = new Binding("ButtonEnabled");
button2.SetBinding(Button.IsEnabledProperty, binding_button2_IsEnabled);
Binding binding_button2_Command = new Binding("ButtonCommand");
button2.SetBinding(Button.CommandProperty, binding_button2_Command);
// buttonResult element
TextBlock buttonResult = new TextBlock();
e_4.Children.Add(buttonResult);
buttonResult.Name = "buttonResult";
buttonResult.HorizontalAlignment = HorizontalAlignment.Left;
Grid.SetColumn(buttonResult, 1);
Grid.SetRow(buttonResult, 2);
Binding binding_buttonResult_Text = new Binding("ButtonResult");
buttonResult.SetBinding(TextBlock.TextProperty, binding_buttonResult_Text);
// e_6 element
TextBlock e_6 = new TextBlock();
e_4.Children.Add(e_6);
e_6.Name = "e_6";
e_6.VerticalAlignment = VerticalAlignment.Center;
e_6.Text = "CheckBox";
//.........这里部分代码省略.........
示例12: Get_TabControl_Items
private static System.Collections.ObjectModel.ObservableCollection<object> Get_TabControl_Items()
{
System.Collections.ObjectModel.ObservableCollection<object> items = new System.Collections.ObjectModel.ObservableCollection<object>();
// e_3 element
TabItem e_3 = new TabItem();
e_3.Name = "e_3";
e_3.HorizontalContentAlignment = HorizontalAlignment.Stretch;
e_3.Header = "Controls";
// e_4 element
Grid e_4 = new Grid();
e_3.Content = e_4;
e_4.Name = "e_4";
RowDefinition row_e_4_0 = new RowDefinition();
row_e_4_0.Height = new GridLength(1F, GridUnitType.Auto);
e_4.RowDefinitions.Add(row_e_4_0);
RowDefinition row_e_4_1 = new RowDefinition();
row_e_4_1.Height = new GridLength(1F, GridUnitType.Auto);
e_4.RowDefinitions.Add(row_e_4_1);
RowDefinition row_e_4_2 = new RowDefinition();
row_e_4_2.Height = new GridLength(1F, GridUnitType.Auto);
e_4.RowDefinitions.Add(row_e_4_2);
RowDefinition row_e_4_3 = new RowDefinition();
row_e_4_3.Height = new GridLength(1F, GridUnitType.Auto);
e_4.RowDefinitions.Add(row_e_4_3);
RowDefinition row_e_4_4 = new RowDefinition();
row_e_4_4.Height = new GridLength(1F, GridUnitType.Auto);
e_4.RowDefinitions.Add(row_e_4_4);
RowDefinition row_e_4_5 = new RowDefinition();
row_e_4_5.Height = new GridLength(1F, GridUnitType.Auto);
e_4.RowDefinitions.Add(row_e_4_5);
RowDefinition row_e_4_6 = new RowDefinition();
row_e_4_6.Height = new GridLength(1F, GridUnitType.Auto);
e_4.RowDefinitions.Add(row_e_4_6);
RowDefinition row_e_4_7 = new RowDefinition();
row_e_4_7.Height = new GridLength(1F, GridUnitType.Auto);
e_4.RowDefinitions.Add(row_e_4_7);
RowDefinition row_e_4_8 = new RowDefinition();
row_e_4_8.Height = new GridLength(1F, GridUnitType.Auto);
e_4.RowDefinitions.Add(row_e_4_8);
RowDefinition row_e_4_9 = new RowDefinition();
row_e_4_9.Height = new GridLength(1F, GridUnitType.Auto);
e_4.RowDefinitions.Add(row_e_4_9);
RowDefinition row_e_4_10 = new RowDefinition();
row_e_4_10.Height = new GridLength(1F, GridUnitType.Auto);
e_4.RowDefinitions.Add(row_e_4_10);
RowDefinition row_e_4_11 = new RowDefinition();
row_e_4_11.Height = new GridLength(1F, GridUnitType.Auto);
e_4.RowDefinitions.Add(row_e_4_11);
ColumnDefinition col_e_4_0 = new ColumnDefinition();
col_e_4_0.Width = new GridLength(1F, GridUnitType.Auto);
e_4.ColumnDefinitions.Add(col_e_4_0);
ColumnDefinition col_e_4_1 = new ColumnDefinition();
e_4.ColumnDefinitions.Add(col_e_4_1);
// e_5 element
TextBlock e_5 = new TextBlock();
e_4.Children.Add(e_5);
e_5.Name = "e_5";
e_5.VerticalAlignment = VerticalAlignment.Center;
e_5.Text = "Button";
// button1 element
Button button1 = new Button();
e_4.Children.Add(button1);
button1.Name = "button1";
button1.Height = 30F;
button1.Width = 200F;
button1.Margin = new Thickness(5F, 5F, 5F, 5F);
button1.HorizontalAlignment = HorizontalAlignment.Left;
button1.TabIndex = 1;
button1.Content = "Button 1";
button1.CommandParameter = "Click Button 1";
Grid.SetColumn(button1, 1);
Grid.SetRow(button1, 0);
Binding binding_button1_Command = new Binding("ButtonCommand");
button1.SetBinding(Button.CommandProperty, binding_button1_Command);
// button2 element
Button button2 = new Button();
e_4.Children.Add(button2);
button2.Name = "button2";
button2.Height = 30F;
button2.Width = 200F;
button2.Margin = new Thickness(5F, 5F, 5F, 5F);
button2.HorizontalAlignment = HorizontalAlignment.Left;
button2.TabIndex = 2;
button2.Content = "Button 2";
button2.CommandParameter = "Click Button 2";
Grid.SetColumn(button2, 1);
Grid.SetRow(button2, 1);
Binding binding_button2_IsEnabled = new Binding("ButtonEnabled");
button2.SetBinding(Button.IsEnabledProperty, binding_button2_IsEnabled);
Binding binding_button2_Command = new Binding("ButtonCommand");
button2.SetBinding(Button.CommandProperty, binding_button2_Command);
// buttonResult element
TextBlock buttonResult = new TextBlock();
e_4.Children.Add(buttonResult);
buttonResult.Name = "buttonResult";
buttonResult.HorizontalAlignment = HorizontalAlignment.Left;
Grid.SetColumn(buttonResult, 1);
Grid.SetRow(buttonResult, 2);
Binding binding_buttonResult_Text = new Binding("ButtonResult");
buttonResult.SetBinding(TextBlock.TextProperty, binding_buttonResult_Text);
//.........这里部分代码省略.........
示例13: InitPopup
private void InitPopup()
{
Binding fontSizeBinding = new Binding("FontSize");
fontSizeBinding.Source = this;
Binding fontWeightBinding = new Binding("FontWeight");
fontWeightBinding.Source = this;
Binding foregroundBinding = new Binding("Foreground");
foregroundBinding.Source = this;
popup = new Popup();
popup.VerticalOffset = SystemTray.IsVisible ? 30 : 0;
Grid grid = new Grid();
grid.MinHeight = MinHeight;
grid.Width = Application.Current.Host.Content.ActualWidth;
PlaneProjection projection = new PlaneProjection()
{
RotationX = -90
};
grid.Projection = projection;
Binding backBinding = new Binding("Background");
backBinding.Source = this;
grid.SetBinding(Grid.BackgroundProperty, backBinding);
ColumnDefinition col1 = new ColumnDefinition()
{
Width = GridLength.Auto
};
ColumnDefinition col2 = new ColumnDefinition()
{
Width = GridLength.Auto
};
ColumnDefinition col3 = new ColumnDefinition();
grid.ColumnDefinitions.Add(col1);
grid.ColumnDefinitions.Add(col2);
grid.ColumnDefinitions.Add(col3);
Image imgIcon = new Image();
imgIcon.Margin = new Thickness(4);
Binding imgBinding = new Binding("Icon");
imgBinding.Source = this;
var imageMaxWidthBinding = new Binding("MinHeight");
imageMaxWidthBinding.Source = this;
imgIcon.SetBinding(Image.MaxWidthProperty, imageMaxWidthBinding);
imgIcon.Stretch = Stretch.Fill;
imgIcon.SetBinding(Image.SourceProperty, imgBinding);
grid.Children.Add(imgIcon);
TextBlock tbkTitle = new TextBlock();
tbkTitle.VerticalAlignment = System.Windows.VerticalAlignment.Center;
tbkTitle.Margin = new Thickness(4);
Binding titleBinding = new Binding("Title");
titleBinding.Source = this;
tbkTitle.SetBinding(TextBlock.TextProperty, titleBinding);
tbkTitle.SetBinding(TextBlock.FontSizeProperty, fontSizeBinding);
tbkTitle.SetBinding(TextBlock.FontWeightProperty, fontWeightBinding);
tbkTitle.SetBinding(TextBlock.ForegroundProperty, foregroundBinding);
tbkTitle.SetValue(Grid.ColumnProperty, 1);
grid.Children.Add(tbkTitle);
TextBlock tbkContent = new TextBlock();
tbkContent.VerticalAlignment = System.Windows.VerticalAlignment.Center;
tbkContent.Margin = new Thickness(4);
Binding contentBinding = new Binding("Content");
contentBinding.Source = this;
tbkContent.SetBinding(TextBlock.TextProperty, contentBinding);
tbkContent.SetBinding(TextBlock.FontSizeProperty, fontSizeBinding);
tbkContent.SetBinding(TextBlock.FontWeightProperty, fontWeightBinding);
tbkContent.SetBinding(TextBlock.ForegroundProperty, foregroundBinding);
tbkContent.SetValue(Grid.ColumnProperty, 2);
grid.Children.Add(tbkContent);
popup.Child = grid;
}
示例14: UpdateMods
protected void UpdateMods()
{
foreach (KeyValuePair<string, Mod> kv in Mod.Mods)
{
bool add = true;
ModViewModel alreadyVM = null;
foreach (ListViewItem i in _Mods)
{
ModViewModel vm = ((ModViewModel)i.DataContext);
if (vm.versions.Values.Contains(kv.Value))
{
add = false;
}
if (vm.ID == kv.Value.ID)
{
alreadyVM = vm;
}
}
if (add)
{
Mod mod = kv.Value;
if (alreadyVM != null)
{
alreadyVM.versions.Add(Mod.Header.ParseModVersion(mod.header.GetVersion()), mod);
alreadyVM.OnPropertyChanged("Version");
alreadyVM.OnPropertyChanged("Name");
}
else
{
ListViewItem item = new ListViewItem();
StackPanel outerPanel = new StackPanel();
outerPanel.Orientation = Orientation.Horizontal;
outerPanel.Margin = new Thickness(-5, 0, 0, 0);
CheckBox checkBox = new CheckBox();
checkBox.SetBinding(CheckBox.IsCheckedProperty, "Selected");
outerPanel.Children.Add(checkBox);
StackPanel panel = new StackPanel();
TextBlock textBlock = new TextBlock();
textBlock.SetBinding(TextBlock.TextProperty, "Name");
panel.Children.Add(textBlock);
TextBlock textBlock2 = new TextBlock();
textBlock2.SetBinding(TextBlock.TextProperty, "Version");
textBlock2.FontSize = 14;
panel.Children.Add(textBlock2);
outerPanel.Children.Add(panel);
ModViewModel mvm = new ModViewModel(mod);
item.DataContext = mvm;
item.Content = outerPanel;
_Mods.Add(item);
}
}
}
foreach (ListViewItem item in _Mods)
{
ModViewModel vm = (ModViewModel)item.DataContext;
vm.Initialized();
}
_FirstBatchLoaded = true;
if (_SelectNewestModVersions)
SelectNewestVersions();
}
示例15: GenerateElement
/// <summary>
/// When overridden in a derived class, gets a read-only element that is bound to the column's <see cref="P:System.Windows.Controls.DataGridBoundColumn.Binding"/> property value.
/// </summary>
/// <param name="cell">The cell that will contain the generated element.</param>
/// <param name="dataItem">The data item represented by the row that contains the intended cell.</param>
/// <returns>
/// A new, read-only element that is bound to the column's <see cref="P:System.Windows.Controls.DataGridBoundColumn.Binding"/> property value.
/// </returns>
protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
{
TextBlock block = new TextBlock
{
Margin = new Thickness(4.0),
VerticalAlignment = VerticalAlignment.Center
};
if (!string.IsNullOrEmpty(Field))
{
converter.DateTimeFormat = this.DateTimeFormat;
converter.DateTimeKind = this.DateTimeKind;
Binding binding =
#if SILVERLIGHT
new Binding(Field);
#else
new Binding("Attributes["+Field+"]");
#endif
binding.Mode = BindingMode.OneWay;
binding.Converter = converter;
block.SetBinding(TextBlock.TextProperty, binding);
}
return block;
}