本文整理汇总了C#中Mono.Xaml.XamlObjectElement类的典型用法代码示例。如果您正苦于以下问题:C# XamlObjectElement类的具体用法?C# XamlObjectElement怎么用?C# XamlObjectElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XamlObjectElement类属于Mono.Xaml命名空间,在下文中一共展示了XamlObjectElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterNamedItem
internal void RegisterNamedItem (XamlObjectElement element, string name)
{
IDictionary rd = CurrentDictionary (element);
if (rd != null && element.X_Key != null) {
throw ParseException ("The name already exists in the tree.");
}
if (element.X_Name != null) {
throw ParseException ("Cannot specify both Name and x:Name attributes.");
}
element.X_Name = name;
FrameworkElement fe = element.FrameworkElement;
if (fe != null)
fe.SetNameOnScope (name, NameScope);
}
示例2: Create
public static XamlAttachedPropertySetter Create (XamlObjectElement element, Accessors accessors)
{
if (accessors == null)
return null;
return new XamlAttachedPropertySetter (element, accessors);
}
示例3: SetValue
public override void SetValue (XamlObjectElement obj, object value)
{
var mutable = value as MutableObject;
if (mutable != null)
value = mutable.Object;
if (!typeof (Binding).IsAssignableFrom (Type)) {
Binding binding = value as Binding;
if (binding != null) {
SetBinding (binding, Element.Object);
return;
}
}
if (!typeof (TemplateBindingExpression).IsAssignableFrom (Type)) {
TemplateBindingExpression tb = value as TemplateBindingExpression;
if (tb != null) {
SetTemplateBinding (tb, obj.Object);
return;
}
}
if (value == null || Type.IsAssignableFrom (value.GetType ())) {
Accessors.Setter (Element.Object, ConvertValue (Type, value));
return;
}
if (typeof (IList).IsAssignableFrom (Type)) {
AddToCollection (value);
return;
}
throw new XamlParseException (
string.Format ("XamlAttachedPropertySetter.SetValue: Could not set value '{0}' to the attached property '{1}.{2}'",
value,
Accessors.DeclaringType,
Accessors.Name)
);
}
示例4: XamlReflectionEventSetter
public XamlReflectionEventSetter (XamlObjectElement element, object target, EventInfo evnt) : base (element, evnt.Name,
Helper.GetConverterFor (evnt, evnt.EventHandlerType))
{
this.target = target;
this.evnt = evnt;
}
示例5: XamlNamePropertySetter
public XamlNamePropertySetter (XamlObjectElement element, DependencyObject target) : base (element, "Name", null)
{
this.target = target;
}
示例6: XamlReflectionPropertySetter
XamlReflectionPropertySetter (XamlObjectElement element, object target, Accessors accessors) : base (element, accessors.Name, accessors.ConverterCreator == null ? null : accessors.ConverterCreator ())
{
this.target = target;
this.accessors = accessors;
if (target is MutableObject)
is_mutable = true;
}
示例7: AddToCollection
private void AddToCollection (XamlObjectElement obj, object value)
{
IList list = accessors.Getter (target) as IList;
if (list == null) {
throw Parser.ParseException ("Collection property in non collection type.");
}
list.Add (value);
}
示例8: ParseXAttribute
private void ParseXAttribute (XamlObjectElement element)
{
switch (reader.LocalName) {
case "Key":
RegisterKeyItem (element, element.Parent, reader.Value);
return;
case "Name":
RegisterNamedItem (element, reader.Value);
return;
case "Class":
// The class attribute is handled when we initialize the element
return;
default:
throw ParseException ("Unknown x: attribute ({0}).", reader.LocalName);
}
}
示例9: ParseAttributeValue
private object ParseAttributeValue (XamlObjectElement element, XamlPropertySetter property)
{
object value = null;
if (IsMarkupExpression (reader.Value))
value = ParseAttributeMarkup (element, property);
else {
value = XamlTypeConverter.ConvertObject (this, element, property.Type, property.Converter, property.Name, reader.Value);
}
return value;
}
示例10: ParseElementAttributes
private void ParseElementAttributes (XamlObjectElement element)
{
if (!reader.HasAttributes)
return;
try {
int ac = reader.AttributeCount;
for (int i = 0; i < reader.AttributeCount; i++) {
reader.MoveToAttribute (i);
ParseAttribute (element);
}
} finally {
// We do this in a finally so error reporting doesn't get all jacked up
reader.MoveToElement();
}
}
示例11: ParseAttribute
private void ParseAttribute (XamlObjectElement element)
{
if (IsMcAttribute ()) {
ParseMcAttribute (element);
return;
}
if (IsXmlnsMapping ()) {
ParseXmlnsMapping (element);
return;
}
if (IsXAttribute ()) {
ParseXAttribute (element);
return;
}
if (IsXmlDirective ()) {
ParseXmlDirective (element);
return;
}
if (IsIgnorable ()) {
return;
}
XamlPropertySetter prop = element.LookupProperty (reader);
if (prop == null)
throw ParseException ("The property {0} was not found.", reader.LocalName);
object value = ParseAttributeValue (element, prop);
prop.SetValue (value);
}
示例12: ParseTextBlockText
private void ParseTextBlockText (XamlObjectElement block)
{
}
示例13: ParseTemplateElement
private void ParseTemplateElement ()
{
Type t = ResolveType ();
if (t == null)
throw ParseException ("Unable to find the type {0}", t);
object o = InstantiateType (t);
XamlObjectElement element = new XamlObjectElement (this, reader.LocalName, o);
OnElementBegin (element);
ParseElementAttributes (element);
string template_xml = reader.ReadInnerXml ();
FrameworkTemplate template = o as FrameworkTemplate;
unsafe {
template.SetXamlBuffer (ParseTemplate, CreateXamlContext (template), template_xml);
}
//
// ReadInnerXml will read our closing </ControlTemplate> tag also, so we manually close things
//
OnElementEnd ();
}
示例14: ParseObjectElement
private void ParseObjectElement ()
{
Type t = ResolveType ();
if (t == null)
throw ParseException ("Unable to find the type {0}.", reader.LocalName);
object o = InstantiateType (t);
XamlObjectElement element = new XamlObjectElement (this, reader.LocalName, o);
SetElementTemplateScopes (element);
OnElementBegin (element);
ParseElementAttributes (element);
// This is a self closing element ie <Rectangle />
if (reader.IsEmptyElement)
OnElementEnd ();
}
示例15: ParseAttributeMarkup
private object ParseAttributeMarkup (XamlObjectElement element, XamlPropertySetter property)
{
MarkupExpressionParser parser = new SL4MarkupExpressionParser (element.Object, property.Name, this, element);
string expression = reader.Value;
object o = parser.ParseExpression (ref expression);
return o;
}