private void HandleSourceAsTable(object source)
        {
            DataTable table = source as DataTable;

            if (source == null)
            {
                return;
            }
            if (!string.IsNullOrEmpty(DataSourcePath))
            {
                if (table != null)
                {
                    DataColumnCollection collection = table.Columns;
                    if (collection.Contains(DataSourcePath))
                    {
                        DataRow dataRow = table.Rows[0];
                        string  value   = _componentFiller.FetchDataFieldValue(table, DataSourcePath);
                        if (value.Contains("#"))
                        {
                            value = value.Replace("#", "@");
                        }
                        TextField.Text = value;
                        if (IsReadOnly)
                        {
                            TextField.Background = Brushes.CadetBlue;
                        }
                        else
                        {
                            TextField.Background = Brushes.White;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///  Call back after the change of the property item source
        /// </summary>
        /// <param name="e">Event to be handled</param>
        protected virtual void OnItemSourceChanged(DependencyPropertyChangedEventArgs e)
        {
            if (e.NewValue == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(_dataField))
            {
                return;
            }

            object objectValue = e.NewValue;

            if (objectValue is DataTable)
            {
                DataTable table = e.NewValue as DataTable;

                this._itemSource = table;
                if (!string.IsNullOrEmpty(_dataField))
                {
                    if (table != null)
                    {
                        DataColumnCollection collection = table.Columns;
                        if (collection.Contains(_dataField))
                        {
                            DataRow dataRow = table.Rows[0];
                            string  colName = _dataField;
                            string  value   = _filler.FetchDataFieldValue(table, _dataField);
                            if (DataAllowed == ControlExt.DataType.Email)
                            {
                                value = value.Replace("#", "@");
                            }
                            TextContent = value;
                            if (IsReadOnly)
                            {
                                TextField.Background = Brushes.CadetBlue;
                            }
                            else
                            {
                                TextField.Background = Brushes.White;
                            }
                        }
                    }
                }
            }
        }