如何在xml文件中定义GRID(WPF)的结构? [英] how to define the structure of a GRID (WPF) in an xml file?

查看:76
本文介绍了如何在xml文件中定义GRID(WPF)的结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

please I want to define the structure of a WPF control in xml.
And I want to do as follows in order to use XamlReader class:
<pre lang="HTML">
<MenuItem Tipo="C"  ContenidoGrid=" <Grid> cualquier contenido </Grid>" Estado="E"/>
</pre>
But in trying to process it, tells me to define it as:

<MenuItem Tipo="C"  ContenidoGrid=" &lt;Grid&gt; cualquier contenido &lt;/Grid&gt;" Estado="E"/>


And I do not want to do it this way because it would not be as readable for me, at the time of editing.
Is there any way to tell xml try everything in ContenidoGrid = ".." , treat it as a simple text and not be posting in special characters (<,>).

Or maybe there is a different kind of structure to xml maybe JSON

推荐答案

您可以使用 XmlDataProvider 。

例如

You can bind the xaml datagrid directly to xml by using the XmlDataProvider.
E.g.
<datagrid.itemssource>
     <binding source="{StaticResource items}" />
 </datagrid.itemssource>
 <datagrid.columns>
     <datagridtextcolumn binding="{Binding XPath=@value}" />
 </datagrid.columns>


这篇关于如何在xml文件中定义GRID(WPF)的结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆