Exemple #1
0
        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);
        }
        internal override FrameworkElement GenerateElement(object childData)
        {
            HyperlinkButton hyperlink = new HyperlinkButton();

            hyperlink.DataContext = childData;
            Binding contentBinding = this.INTERNAL_GetBinding(DataGridHyperlinkColumn.ContentBindingProperty); //we get the Binding in the ContentBinding property set by the user.
            Binding b = this.INTERNAL_GetBinding(DataGridBoundColumn.BindingProperty);                         //we get the Binding in the Binding property set by the user.

            if (b != null)
            {
                if (b.Mode == BindingMode.OneWay)
                {
                    if (!b.INTERNAL_WasModeSetByUserRatherThanDefaultValue())
                    {
                        b.Mode = BindingMode.TwoWay;
                    }
                }
                hyperlink.SetBinding(HyperlinkButton.NavigateUriProperty, b);
            }
            if (contentBinding != null)
            {
                if (contentBinding.Mode == BindingMode.OneWay)
                {
                    if (!contentBinding.INTERNAL_WasModeSetByUserRatherThanDefaultValue())
                    {
                        contentBinding.Mode = BindingMode.TwoWay;
                    }
                }
                hyperlink.SetBinding(HyperlinkButton.ContentProperty, contentBinding);
            }
            else if (b != null)
            {
                hyperlink.SetBinding(HyperlinkButton.ContentProperty, b);
            }
            else if (childData is string)
            {
                hyperlink.NavigateUri = new Uri((string)childData);
                hyperlink.Content     = (string)childData;
            }
            return(hyperlink);
        }
Exemple #3
0
        internal override FrameworkElement GenerateElement(object childData)
        {
            HyperlinkButton hyperlink = new HyperlinkButton();

            hyperlink.DataContext = childData;
            Binding contentBinding = ContentBinding as Binding;
            Binding b = Binding as Binding;

            if (b != null)
            {
                if (b.Mode == BindingMode.OneWay)
                {
                    if (!b.INTERNAL_WasModeSetByUserRatherThanDefaultValue())
                    {
                        b.Mode = BindingMode.TwoWay;
                    }
                }
                hyperlink.SetBinding(HyperlinkButton.NavigateUriProperty, b);
            }
            if (contentBinding != null)
            {
                if (contentBinding.Mode == BindingMode.OneWay)
                {
                    if (!contentBinding.INTERNAL_WasModeSetByUserRatherThanDefaultValue())
                    {
                        contentBinding.Mode = BindingMode.TwoWay;
                    }
                }
                hyperlink.SetBinding(HyperlinkButton.ContentProperty, contentBinding);
            }
            else if (b != null)
            {
                hyperlink.SetBinding(HyperlinkButton.ContentProperty, b);
            }
            else if (childData is string)
            {
                hyperlink.NavigateUri = new Uri((string)childData);
                hyperlink.Content     = (string)childData;
            }
            return(hyperlink);
        }
Exemple #4
0
        /// <summary>
        /// Makes the contact chooser.
        /// </summary>
        /// <param name="setting">The setting.</param>
        /// <param name="p">The p.</param>
        private void MakeContactChooser(Setting setting, out StackPanel p)
        {
            try {
                p = new StackPanel {
                    Orientation = Orientation.Vertical
                };

                TextBlock tbFriendlyName = MakeCaption(setting);
                if (string.IsNullOrEmpty(setting.ContactDisplayName))
                {
                    setting.ContactDisplayName = "Choose Contact";
                }
                var bButton = new HyperlinkButton {
                    HorizontalAlignment = HorizontalAlignment.Left,
                    Margin = new Thickness(-5, 0, 0, 0)
                };
                bButton.SetBinding(ContentControl.ContentProperty, new Binding("ContactDisplayName")
                {
                    Mode = BindingMode.TwoWay, Source = setting
                });
                bButton.Click += bButton_Click;
                p.Children.Add(tbFriendlyName);
                p.Children.Add(bButton);

                var tbCc = new TextBox {
                    Name         = String.Format((string)"txt{0}", (object)setting.Name.Replace(" ", String.Empty)),
                    Height       = 72,
                    MaxLength    = 50,
                    TextWrapping = TextWrapping.NoWrap
                };
                tbCc.SetBinding(TextBox.TextProperty, new Binding("Value")
                {
                    Mode = BindingMode.TwoWay, Source = setting
                });

                tbCc.InputScope = new InputScope {
                    Names =
                    {
                        new InputScopeName {
                            NameValue = (setting.AddressType == addressType.Email
                                                                                                         ? InputScopeNameValue.EmailNameOrAddress :
                                         InputScopeNameValue.TelephoneNumber)
                        }
                    }
                };

                var lbAddressType = new ListPicker {
                    Header = "DEFAULT SEND TYPE"
                };
                IEnumerable <FieldInfo> fields = (typeof(addressType)).GetFields().Skip(1);
                lbAddressType.ItemsSource = from field in fields select field.Name;
                lbAddressType.SetBinding(ListPicker.SelectedItemProperty, new Binding("AddressType")
                {
                    Converter = new EnumValueConverter(), Mode = BindingMode.TwoWay, Source = setting
                });
                p.Children.Add(tbCc);
                p.Children.Add(lbAddressType);
            } catch (Exception e) {
                p = null;
            }
        }
Exemple #5
0
        // 依存関係プロパティに値がセットされたときに呼び出されるメソッド
        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);
                            }
                            else if (entitiy is HashTag)
                            {
                                var en = entitiy as HashTag;
                                link.Content          = "#" + en.text;
                                uiContainer.Child     = link;
                                link.CommandParameter = "#" + en.text;
                                link.SetBinding(HyperlinkButton.CommandProperty, searchCommandBinding);
                            }
                            else if (entitiy is TweetMedia)
                            {
                                var en = entitiy as TweetMedia;

                                Button btn = new Button();
                                btn.Width = (double)Application.Current.Resources["previewImageWidth"];

                                //btn.HorizontalAlignment = HorizontalAlignment.Stretch;
                                btn.Height = (double)Application.Current.Resources["previewImageHeight"];
                                btn.Style  = Application.Current.Resources["NeuroniaTimelineImageButtonStyle"] as Style;
                                var imageBrush = new ImageBrush()
                                {
                                    ImageSource = new BitmapImage(new Uri(en.media_url)), Stretch = Stretch.UniformToFill
                                };
                                btn.Background       = imageBrush;
                                btn.CommandParameter = en;
                                btn.SetBinding(Button.CommandProperty, previewImageCommandBinding);
                                var flyout = Application.Current.Resources["ImagePreviewFlyout"] as Flyout;
                                flyout.Placement = FlyoutPlacementMode.Top;

                                var grid = (flyout.Content as Grid);

                                btn.Flyout        = flyout;
                                uiContainer.Child = btn;

                                para.Inlines.Add(new LineBreak());
                            }
                            para.Inlines.Add(uiContainer);
                            seek = end;
                        }

                        para.Inlines.Add(new Run {
                            Text = back, Foreground = runForeGround, FontFamily = tweetFontFamily, FontSize = fontSize
                        });
                    }
                    else
                    {
                        para.Inlines.Add(new Run {
                            Text = tweet.text, Foreground = runForeGround, FontFamily = tweetFontFamily, FontSize = fontSize
                        });
                    }

                    block.Blocks.Add(para);
                }
                catch (Exception ee)
                {
                    //Debug.WriteLine(value.ToString());
                }
            }


            (d as ContentControl).Content = block;
        }
        private void UpdateTemplate()
        {
            var stackPanel = new StackPanel {
                Orientation = Orientation.Vertical
            };

            Content = stackPanel;

            var titleText = new TextBlock
            {
                Style        = _pageSubHeaderTextStyle,
                TextWrapping = TextWrapping.Wrap,
            };

            stackPanel.Children.Add(titleText);
            var hasTitle = PopupInfo != null && PopupInfo.Title != null && PopupInfo.Title.Trim().Length > 0;

            if (hasTitle)
            {
                titleText.SetBinding(InlineCollectionProperty, new Binding
                {
                    Path               = new PropertyPath("Attributes"),
                    Source             = this,
                    Converter          = new StringFormatToInlineCollectionConverter(),
                    ConverterParameter = PopupInfo.Title
                });
            }
            if (PopupInfo != null && PopupInfo.Description != null && PopupInfo.Description.Trim().Length > 0)
            {
                if (!hasTitle)
                {
                    hasTitle = true;
                    titleText.SetBinding(InlineCollectionProperty, new Binding
                    {
                        Path               = new PropertyPath("Attributes"),
                        Source             = this,
                        Converter          = new StringFormatToInlineCollectionConverter(),
                        ConverterParameter = PopupInfo.Description
                    });
                }
                var desc = new RichTextBlock
                {
                    FontSize   = _controlContentThemeFontSize,
                    FontFamily = _contentControlThemeFontFamily
                };
                stackPanel.Children.Add(desc);

                var p = new Paragraph();
                desc.Blocks.Add(p);

                BindingOperations.SetBinding(p, HtmlToTextConverter.HtmlToInlinesProperty, new Binding
                {
                    Path               = new PropertyPath("Attributes"),
                    Source             = this,
                    Converter          = new HtmlToTextConverter(),
                    ConverterParameter = PopupInfo.Description
                });
            }
            else //Show attribute list
            {
                List <FieldInfo> displayFields = null;
                if (PopupInfo != null && PopupInfo.FieldInfos != null)
                {
                    displayFields = new List <FieldInfo>(PopupInfo.FieldInfos.Where(a => a.IsVisible));
                }
                if (displayFields == null)
                {
                    return;
                }
                var attributes = Attributes as IDictionary <string, object>;
                foreach (var item in displayFields)
                {
                    var sp = new StackPanel();
                    stackPanel.Children.Add(sp);
                    var l = new TextBlock
                    {
                        Style        = _baselineTextStyle,
                        Margin       = new Thickness(0, 10, 0, 0),
                        Text         = item.Label ?? item.FieldName,
                        Foreground   = new SolidColorBrush(Colors.DarkGray),
                        TextWrapping = TextWrapping.Wrap,
                        TextTrimming = TextTrimming.WordEllipsis
                    };
                    sp.Children.Add(l);
                    if (!hasTitle)
                    {
                        hasTitle = true;
                        titleText.SetBinding(InlineCollectionProperty, new Binding
                        {
                            Path   = new PropertyPath(string.Format("Attributes[{0}]", item.FieldName)),
                            Source = this
                        });
                    }
                    var useHyperlink = attributes != null && attributes.ContainsKey(item.FieldName) &&
                                       attributes[item.FieldName] is string && ((string)attributes[item.FieldName]).StartsWith("http");
                    if (useHyperlink || string.Equals("url", item.FieldName, StringComparison.OrdinalIgnoreCase))
                    {
                        var hyperlink = new HyperlinkButton();
                        sp.Children.Add(hyperlink);
                        hyperlink.SetBinding(HyperlinkButton.NavigateUriProperty,
                                             new Binding
                        {
                            Path   = new PropertyPath(string.Format("Attributes[{0}]", item.FieldName)),
                            Source = this
                        });
                        hyperlink.SetBinding(ContentProperty,
                                             new Binding
                        {
                            Path   = new PropertyPath(string.Format("Attributes[{0}]", item.FieldName)),
                            Source = this
                        });
                        hyperlink.Template = (ControlTemplate)XamlReader.Load(
                            "<ControlTemplate TargetType='HyperlinkButton' xmlns='http://schemas.microsoft.com/client/2007' >" +
                            "<TextBlock Text='{TemplateBinding Content}' Padding='0' Margin='0' RenderTransformOrigin='0.5,0.5' TextWrapping='Wrap' TextTrimming ='WordEllipsis'>" +
                            "<TextBlock.RenderTransform>" +
                            "<CompositeTransform TranslateY='5' />" +
                            "</TextBlock.RenderTransform>" +
                            "</TextBlock>" +
                            "</ControlTemplate>");
                        hyperlink.FontFamily = new FontFamily("Segoe UI Light");
                        hyperlink.FontWeight = FontWeights.Normal;
                        hyperlink.Margin     = new Thickness(0);
                        hyperlink.Padding    = new Thickness(0);
                    }
                    else
                    {
                        var t = new TextBlock
                        {
                            Style        = _baselineTextStyle,
                            Margin       = new Thickness(0, 10, 0, 0),
                            TextWrapping = TextWrapping.Wrap,
                            TextTrimming = TextTrimming.WordEllipsis
                        };
                        sp.Children.Add(t);
                        t.SetBinding(TextBlock.TextProperty, new Binding
                        {
                            Path   = new PropertyPath(string.Format("Attributes[{0}]", item.FieldName)),
                            Source = this
                        });
                    }
                }
            }
            if (PopupInfo != null && PopupInfo.MediaInfos != null)
            {
                foreach (var item in PopupInfo.MediaInfos)
                {
                    if (!string.IsNullOrEmpty(item.Title))
                    {
                        var mediaTitle = new TextBlock
                        {
                            Style        = _baselineTextStyle,
                            Margin       = new Thickness(0, 10, 0, 0),
                            FontWeight   = FontWeights.Bold,
                            TextWrapping = TextWrapping.Wrap,
                            TextTrimming = TextTrimming.WordEllipsis
                        };
                        stackPanel.Children.Add(mediaTitle);
                        if (!hasTitle)
                        {
                            hasTitle = true;
                            titleText.SetBinding(InlineCollectionProperty, new Binding
                            {
                                Path               = new PropertyPath("Attributes"),
                                Source             = this,
                                Converter          = new StringFormatToInlineCollectionConverter(),
                                ConverterParameter = item.Title
                            });
                        }
                        mediaTitle.SetBinding(TextBlock.TextProperty, new Binding
                        {
                            Path               = new PropertyPath("Attributes"),
                            Source             = this,
                            Converter          = new StringFormatToStringConverter(),
                            ConverterParameter = item.Title
                        });
                    }
                    if (!string.IsNullOrEmpty(item.Caption))
                    {
                        var mediaCaption = new TextBlock
                        {
                            Style        = _baselineTextStyle,
                            Margin       = new Thickness(0, 10, 0, 0),
                            FontStyle    = FontStyle.Italic,
                            TextWrapping = TextWrapping.Wrap,
                            TextTrimming = TextTrimming.WordEllipsis
                        };
                        stackPanel.Children.Add(mediaCaption);
                        if (!hasTitle)
                        {
                            hasTitle = true;
                            titleText.SetBinding(InlineCollectionProperty, new Binding
                            {
                                Path               = new PropertyPath("Attributes"),
                                Source             = this,
                                Converter          = new StringFormatToInlineCollectionConverter(),
                                ConverterParameter = item.Caption
                            });
                        }
                        mediaCaption.SetBinding(TextBlock.TextProperty, new Binding
                        {
                            Path               = new PropertyPath("Attributes"),
                            Source             = this,
                            Converter          = new StringFormatToStringConverter(),
                            ConverterParameter = item.Caption
                        });
                    }

                    IEnumerable <KeyValuePair <string, string> > fieldMappings = null;
                    if (PopupInfo != null && PopupInfo.FieldInfos != null)
                    {
                        fieldMappings = from f in PopupInfo.FieldInfos
                                        select(new KeyValuePair <string, string>(f.FieldName, f.Label ?? f.FieldName));
                    }
                    BaseChart chart = null;
                    switch (item.Type)
                    {
                    case MediaType.Image:
                        var imageGrid = new Grid();
                        stackPanel.Children.Add(imageGrid);
                        if (!string.IsNullOrEmpty(item.Value.SourceUrl))
                        {
                            var image = new Image
                            {
                                Margin  = new Thickness(0, 10, 0, 0),
                                Width   = 200d,
                                Height  = 200d,
                                Stretch = Stretch.UniformToFill
                            };
                            imageGrid.Children.Add(image);
                            image.SetBinding(Image.SourceProperty, new Binding
                            {
                                Path               = new PropertyPath("Attributes"),
                                Source             = this,
                                Converter          = new StringFormatToBitmapSourceConverter(),
                                ConverterParameter = item.Value.SourceUrl
                            });
                        }
                        if (!string.IsNullOrEmpty(item.Value.LinkUrl))
                        {
                            var hyperlinkButton = new HyperlinkButton
                            {
                                Margin = new Thickness(0, 10, 0, 0),
                                Width  = 200d,
                                Height = 200d
                            };
                            imageGrid.Children.Add(hyperlinkButton);
                            hyperlinkButton.SetBinding(HyperlinkButton.NavigateUriProperty, new Binding
                            {
                                Path               = new PropertyPath("Attributes"),
                                Source             = this,
                                Converter          = new StringFormatToUriConverter(),
                                ConverterParameter = item.Value.LinkUrl
                            });
                        }
                        break;

                    case MediaType.BarChart:
                        chart = new BarChart();
                        break;

                    case MediaType.ColumnChart:
                        chart = new ColumnChart();
                        break;

                    case MediaType.LineChart:
                        chart = new LineChart();
                        break;

                    case MediaType.PieChart:
                        //string normalizeField = item.Value.NormalizeField;
                        chart = new PieChart();
                        break;
                    }
                    if (chart != null)
                    {
                        var fieldString    = string.Join(",", item.Value.Fields);
                        var normalizeField = item.Value.NormalizeField;
                        if (!string.IsNullOrEmpty(normalizeField) && !normalizeField.Equals("null"))
                        {
                            fieldString += BaseChart.NormalizeSeparator + normalizeField;
                        }
                        chart.Margin   = new Thickness(0, 10, 0, 0);
                        chart.Fields   = fieldString;
                        chart.Height   = 200;
                        chart.Width    = 200;
                        chart.FontSize = 10d;
                        var keyValuePairs = fieldMappings as KeyValuePair <string, string>[] ?? fieldMappings.ToArray();
                        if (keyValuePairs.Any())
                        {
                            chart.KeyToLabelDictionary = new ResourceDictionary();
                            foreach (var pair in keyValuePairs)
                            {
                                chart.KeyToLabelDictionary[pair.Key] = pair.Value;
                            }
                        }
                        stackPanel.Children.Add(chart);
                        chart.SetBinding(DataContextProperty, new Binding
                        {
                            Path   = new PropertyPath("Attributes"),
                            Source = this,
                        });
                    }
                }
            }
        }
Exemple #7
0
        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:
                HyperlinkButton hb = new HyperlinkButton();
                if (dfItem.ReferenceDataInfo != null)
                {
                    binding.Path = new PropertyPath(dfItem.ReferenceDataInfo.ReferencedMember + ".Text");
                }
                hb.Click += (o, e) =>
                {
                    var sourceOjb = hb.DataContext.GetObjValue(dfItem.ReferenceDataInfo.ReferencedMember + ".Value");
                    CommonFunction.ShowExtendForm(sourceOjb);
                };
                hb.SetBinding(HyperlinkButton.ContentProperty, binding);
                c = hb;
                break;
            }
            return(c);
        }