本文整理汇总了C#中System.Windows.Controls.HyperlinkButton.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# HyperlinkButton.SetBinding方法的具体用法?C# HyperlinkButton.SetBinding怎么用?C# HyperlinkButton.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.HyperlinkButton
的用法示例。
在下文中一共展示了HyperlinkButton.SetBinding方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateControl
private FrameworkElement CreateControl(DataFieldItem dfItem)
{
ControlType cType = dfItem.CType;
Binding binding = new Binding();
binding.Path = new PropertyPath(dfItem.PropertyName);
binding.Mode = BindingMode.TwoWay;
binding.Converter = new CommonConvert(dfItem);
FrameworkElement c = null;
switch (cType)
{
case ControlType.Label:
TextBlock tbx = new TextBlock();
if (dfItem.ReferenceDataInfo != null)
{
binding.Path = new PropertyPath(dfItem.ReferenceDataInfo.ReferencedMember + ".Text");
}
tbx.SetBinding(TextBlock.TextProperty, binding);
c = tbx;
break;
case ControlType.TextBox:
TextBox tb = new TextBox();
tb.SetBinding(TextBox.TextProperty, binding);
tb.IsReadOnly = (IsReadOnly || dfItem.IsReadOnly);
tb.MaxLength = dfItem.MaxLength;
if ( dfItem.DataType.ToLower() == "decimal" || dfItem.DataType.ToLower() == "datetime")
{
tb.TextAlignment = TextAlignment.Right;
}
c = tb;
break;
case ControlType.Combobox:
ComboBox cbb = new ComboBox();
if (dfItem.ReferenceDataInfo != null)
{
cbb.ItemsSource = this.GetItemSource(dfItem.ReferenceDataInfo.Type);
cbb.DisplayMemberPath = "Text";
binding.Path = new PropertyPath(dfItem.ReferenceDataInfo.ReferencedMember);
}
cbb.SetBinding(ComboBox.SelectedItemProperty, binding);
cbb.IsEnabled = !(IsReadOnly || dfItem.IsReadOnly);
c = cbb;
break;
case ControlType.LookUp:
FBLookUp lookUp = new FBLookUp();
lookUp.OperationType = this.OperationType;
lookUp.DisplayMemberPath = dfItem.PropertyName;
if (dfItem.ReferenceDataInfo != null)
{
lookUp.DisplayMemberPath = dfItem.ReferenceDataInfo.ReferencedMember + ".Text";
if (!string.IsNullOrEmpty(dfItem.ReferenceDataInfo.TextPath))
{
lookUp.DisplayMemberPath = dfItem.ReferenceDataInfo.TextPath;
}
lookUp.LookUpType = dfItem.ReferenceDataInfo.Type;
binding.Path = new PropertyPath(dfItem.ReferenceDataInfo.ReferencedMember);
}
lookUp.SetBinding(LookUp.SelectItemProperty, binding);
lookUp.ReferencedDataInfo = dfItem.ReferenceDataInfo;
lookUp.Parameters = dfItem.ReferenceDataInfo.Parameters;
lookUp.IsReadOnly = (IsReadOnly || dfItem.IsReadOnly);
c = lookUp;
break;
case ControlType.Remark:
TextBox tbRemark = new TextBox();
tbRemark.AcceptsReturn = true;
tbRemark.TextWrapping = TextWrapping.Wrap;
//tbRemark.Height = 66;
//tbRemark.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
//tbRemark.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
tbRemark.SetBinding(TextBox.TextProperty, binding);
c = tbRemark;
tbRemark.IsReadOnly = (IsReadOnly || dfItem.IsReadOnly);
tbRemark.MaxLength = dfItem.MaxLength;
break;
case ControlType.DatePicker:
DatePicker datePicker = new DatePicker();
datePicker.SelectedDateFormat = DatePickerFormat.Short;
datePicker.SetBinding(DatePicker.SelectedDateProperty, binding);
c = datePicker;
datePicker.IsEnabled = !(IsReadOnly || dfItem.IsReadOnly);
break;
case ControlType.DateTimePicker:
DateTimePicker dateTimePicker = new DateTimePicker();
dateTimePicker.SetBinding(DateTimePicker.ValueProperty, binding);
c = dateTimePicker;
dateTimePicker.IsEnabled = !(IsReadOnly || dfItem.IsReadOnly);
break;
// Add By LVCHAO 2011.01.30 14:46
case ControlType.HyperlinkButton:
//.........这里部分代码省略.........
示例2: getHyperlinkButton
private HyperlinkButton getHyperlinkButton(string dataBindablePropertyName)
{
HyperlinkButton hyperlink = null;
try
{
TextBlock textBlock = new TextBlock()
{
Foreground = new SolidColorBrush(Colors.Blue),
Margin = new Thickness(0),
TextDecorations = TextDecorations.Underline,
VerticalAlignment = VerticalAlignment.Top,
FontWeight = FontWeights.Normal
};
textBlock.SetBinding(TextBlock.TextProperty, new System.Windows.Data.Binding(dataBindablePropertyName));
hyperlink = new HyperlinkButton()
{
Content = textBlock,
TargetName = "_blank",
Background = new SolidColorBrush(Colors.Transparent),
VerticalAlignment = VerticalAlignment.Top
};
hyperlink.SetBinding(HyperlinkButton.NavigateUriProperty, new System.Windows.Data.Binding(dataBindablePropertyName) { Converter = StringToUriConverter });
}
catch { }
return hyperlink;
}