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


C# HyperlinkButton.SetBinding方法代码示例

本文整理汇总了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:
//.........这里部分代码省略.........
开发者ID:JuRogn,项目名称:OA,代码行数:101,代码来源:FieldForm.xaml.cs

示例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;
        }
开发者ID:Esri,项目名称:arcgis-viewer-silverlight,代码行数:27,代码来源:CustomDataGridColumn.cs


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