我如何在Vb代码而不是Xaml中执行此操作? [英] How Can I Do This In Vb Code Instead Of Xaml ?

查看:67
本文介绍了我如何在Vb代码而不是Xaml中执行此操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <   Window.Resources  >  
< XmlDataProvider 来源 = e:\clients.xml

XPath = 客户 x:键 = custData / >
< ; / Window.Resources >
< 网格 >
< DataGrid 名称 = CustomerGrid < span class =code-attribute>
AutoGenerateColumns = False

< span class =code-attribute> ItemsSource = {Binding Source = {StaticResource custData},XPath = *} >
< DataGrid.Columns >
< DataGridTextColumn 绑定 = {绑定XPath = @ Name} < span class =code-attribute>

标题 = 名称 / >
< DataGridTextColumn 绑定 = {绑定XPath = @ Address}

< span class =code-attribute>
标题 = 地址 / >
< DataGridTextColumn Binding = {Binding XPath = @ City}

标题 = 城市 / >
< DataGridTextColumn Binding = {Binding XPath = @ Phone}

< span class =code-attribute> 标题 = 电话 / >
< / DataGrid.Columns >
< / DataGrid >

解决方案

尝试从TextBox填充DataGrid(VB,wp f) [ ^ ]。

<Window.Resources>
        <XmlDataProvider Source="e:\clients.xml" 

                         XPath="Customers" x:Key="custData" />
    </Window.Resources>
    <Grid>
        <DataGrid Name="CustomerGrid" AutoGenerateColumns="False"

                  ItemsSource="{Binding Source={StaticResource custData},XPath=*}">
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding XPath=@Name}"

                                    Header="Name" />
                <DataGridTextColumn Binding="{Binding XPath=@Address}" 

                                    Header="Address" />
                <DataGridTextColumn Binding="{Binding XPath=@City}" 

                                    Header="City" />
                <DataGridTextColumn Binding="{Binding XPath=@Phone}" 

                                    Header="Phone" />
            </DataGrid.Columns>
        </DataGrid>

解决方案

Try Filling DataGrid from TextBox (VB, wpf)[^].


这篇关于我如何在Vb代码而不是Xaml中执行此操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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