And*_*ith 11 wpf binding dependency-properties markup-extensions c#-3.0
是否有可能DependencyProperty在MarkupExtension派生类中?
public class GeometryQueryExtension : MarkupExtension
{
public XmlDataProvider Source { get; set; }
public string XPath { get; set; }
public static readonly DependencyProperty ArgumentProperty = DependencyProperty.RegisterAttached(
"Argument",
typeof(string),
typeof(GeometryQueryExtension)); // this wont work because GeometryQueryExtension is not a DependencyProperty
public string Argument
{
get
{
return (string)GetValue(ArgumentProperty); // this wont even compile because GeometryQueryExtension doesnt derive from a class which has GetValue
}
set
{
SetValue(ArgumentProperty,value);// this wont even compile because GeometryQueryExtension doesnt derive from a class which has SetValue
}
}
}
Run Code Online (Sandbox Code Playgroud)
该扩展名用于以下代码段.
<Label.Content>
<local:GeometryQueryExtension Source="{StaticResource shapesDS}">
<local:GeometryQueryExtension.XPath>
/Shapes/Geometry/{0}
</local:GeometryQueryExtension.XPath>
<local:GeometryQueryExtension.Argument>
<Binding XPath="Geometry"/> <!-- will throw exception when processing this bind -->
</local:GeometryQueryExtension.Argument>
</local:GeometryQueryExtension>
</Label.Content>
Run Code Online (Sandbox Code Playgroud)
是否有可能建立这样的扩展或我只是咆哮错误的树?(上面的代码不会编译和运行,但我在这里发布它以最好地说明问题).
| 归档时间: |
|
| 查看次数: |
3003 次 |
| 最近记录: |