当放置在WPF MainWindow中时,UserControl中的DatagGrid不显示数据 [英] DatagGrid in a UserControl does not show data when placed in WPF MainWindow

查看:110
本文介绍了当放置在WPF MainWindow中时,UserControl中的DatagGrid不显示数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我是WPF的新手,所以我正在开发一个测试应用程序,以查看谁可以正常工作.还是不?

我创建了一个新的WPF RibbonMenu应用程序,设置了功能区菜单炫酷工具,将WPF UserControl添加到了项目中,连接到我的SQL DB在DB中创建了一个View,然后在DataSource中将其连接起来,拖了新视图到UserControl上...在项目中添加了一个新的Window1,并将UC放置在新的window1上...到目前为止效果很好,构建时没有错误.

现在,当我运行该应用程序并按下RibbonMenu Window1上的一个按钮时,将显示所有字段...但是没有数据!
我打开MainWindow并将UC直接放在Content区域上...运行应用程序NO DATA ...该死!

我将DataSet字段直接放在MainWindow上,再次运行该应用程序.
那么,将数据集放置在UC中并将UC放入要填充字段的窗口中时,我会丢失什么?

我已经在MainWindow上看到了几个UserControls的示例,并且都在MainWindow的XAML中使用了硬编码的引用.在此应用程序中这是不可能的,因为我将根据用户在RibbonMenu中选择(按下)的按钮来在MainWindow或其他窗口中显示具有不同数据集的几个不同的UC.

谢谢

任何人都知道如何执行此操作的示例吗?

Hi,
I am new to this WPF stuff and so I am working on a test app to see who it all works. or doesn''t?

I have created a new WPF RibbonMenu application, set up the Ribbon Menu cool tool, added a WPF UserControl to the project, connected to my SQL DB created a View in the DB, then connected to it in the DataSource pain, Dragged the new view onto the UserControl... added a new Window1 to the project and placed the UC on the new window1... so far so good and no errors when built.

Now when I run the app and press a button on the RibbonMenu Window1 is displayed and the fields are all displayed... BUT NO DATA!!!

I opened the MainWindow and placed the UC directly on the Content area... run the app NO DATA... damn!

I placed the DataSet fields directly on the MainWindow Run the app again... YEAH DATA!!!

So what am I missing when placing the DataSet within a UC and the UC into a Window for the fields to be populated?

I have seen several examples of UserControls on the MainWindow and all use a hard coded reference in the XAML of the MainWindow. That is not possible in this app as I will be displaying several different UC''s with different datasets within the MainWindow or other windows depending on which button the user has selected (pressed) in the RibbonMenu.

Thanks

Anyone know of an example of how to do this?

推荐答案

如果您拥有用户控件的源代码,则可能希望将其附加到项目中并进行调试它.具体来说,您需要查看将日期提取到控件中的位-看起来那里可能有问题.您还应该查看一下连接字符串,以确保它指向正确的服务器.
If you have the source code for your user control, you might want to attach it to your project and debug it. Specifically, you need to look at the bits that are fetching date into your control - looks like something might be wrong there. You should also take a look at your connection string to make sure that it is pointing to the right server.


从您的问题中得到一个奇怪的印象,我感到很奇怪,您希望WPF能够读取您的仔细考虑并确定要用于填充DataGrid实例的数据,以及如何将数据映射到网格上.

我不是真的,但是我给人的印象是,因为您从未提到 数据绑定 ,也没有提到您尝试手动创建任何填充方法的尝试.在不接近问题实质的情况下,您在问题中插入了惊人的许多字母.

看来您需要回到一般概念.

查看演练:在DataGrid控件中显示来自SQL Server数据库的数据: http://msdn.microsoft.com/en-us/library/ee340709.aspx [ ^ ].

它应该给您一个想法.尝试查找和阅读System.Windows.Controls.DataGrid( http://msdn .microsoft.com/en-us/library/system.windows.controls.datagrid.aspx [ http://www.wpftutorial.net/DataGrid.html [ WPF数据网格简介 [ http://www.c-sharpcorner.com/UploadFile/mahesh/WpfDGP1092720092009111405AM/WpfDGP1.aspx [ ^ ].

您可以在Google上找到更多信息-这个话题太受欢迎了.

—SA
From your Question a strange I got a strange impression that you expect WPF to read your mind and figure out what data your want to use for population of your DataGrid instance and how your data should be mapped onto your grid.

I cannot be true, but I got this impression because you never mention data binding, nor you mentioned any your attempts to create any population methods manually. You put amazingly many letters in your Question while not approaching the essence of the problem.

It looks like you need to go back to general concepts.

Look at the Walkthrough: Display Data from a SQL Server Database in a DataGrid Control: http://msdn.microsoft.com/en-us/library/ee340709.aspx[^].

It should give you an idea. Try to find and read other introductory material around System.Windows.Controls.DataGrid (http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid.aspx[^]), see some introductory articles:

http://www.wpftutorial.net/DataGrid.html[^],
Introduction to the WPF DataGrid[^],
http://www.c-sharpcorner.com/UploadFile/mahesh/WpfDGP109272009111405AM/WpfDGP1.aspx[^].

You can Google out a lot more — this topic is too popular.

—SA


由于我无法通过添加评论"发布代码,因此我将在此处重试...
FRIST ...来自MainWindow的代码,窗口上有DataSet.Grid ...这将按预期在Grid中显示数据.
Since I am unable to post my code via "Add Comment" I will try again here...
FRIST... code from MainWindow with DataSet.Grid on the window... this displays the data as expected in the Grid.
<r:RibbonWindow x:Class="WpfRibbonApplication1.MainWindow"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"

        Title="MainWindow"

        x:Name="RibbonWindow"

        Width="1024" Height="768" xmlns:my="clr-namespace:WpfRibbonApplication1" Loaded="RibbonWindow_Loaded">
    <r:RibbonWindow.Resources>
        <my:YachtLogPro_SQLDataSet x:Key="yachtLogPro_SQLDataSet" />
        <CollectionViewSource x:Key="vesselDetails_VViewSource" Source="{Binding Path=VesselDetails_V, Source={StaticResource yachtLogPro_SQLDataSet}}" />
    </r:RibbonWindow.Resources>
    <Grid x:Name="LayoutRoot" DataContext="{StaticResource vesselDetails_VViewSource}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <r:Ribbon x:Name="Ribbon" Height="137" VerticalAlignment="Top">
            <r:Ribbon.ApplicationMenu>
                <r:RibbonApplicationMenu SmallImageSource="/WpfRibbonApplication1;component/Images/YachtLog_Icon_Globe2.gif">
                    <r:RibbonApplicationMenuItem Header="Print"

                                                     x:Name="mnuPrint"

                                                    ImageSource="/WpfRibbonApplication1;component/Images/Print-icon.png"

                                                    Click="mnuPrint_Click" />
                    <r:RibbonApplicationMenuItem Header="Help"

                                                     x:Name="mnuHelp"

                                                     ImageSource="/WpfRibbonApplication1;component/Images/Help.png"

                                                     Click="mnuHelp_Click" />
                    <r:RibbonApplicationMenuItem Header="Exit"

                           x:Name="mnuExit"

                           ImageSource="/WpfRibbonApplication1;component/Images/exit.png"

                           Click="mnuExit_Click" />
                </r:RibbonApplicationMenu>
            </r:Ribbon.ApplicationMenu>

            <r:RibbonTab x:Name="tabLogs"

                         Header="Logs"

                         Visibility="Visible" >
                <r:RibbonGroup x:Name="grpNShipsLog" >
                    <r:RibbonGroup.Background>
                        <RadialGradientBrush>
                            <GradientStop Color="Black" Offset="0" />
                            <GradientStop Color="White" Offset="1" />
                            <GradientStop Color="#FF38E538" Offset="0.006" />
                        </RadialGradientBrush>
                    </r:RibbonGroup.Background>
                    <r:RibbonButton x:Name="btnSLSearch"

                                         LargeImageSource="/WpfRibbonApplication1;component/Images/Ships_Log.gif"

                                         Label="Ships"

                                         Click="btnSLSearch_Click" />
                    <r:RibbonButton x:Name="btnSLAdd"

                                         SmallImageSource="/WpfRibbonApplication1;component/Images/Add-icon.png"

                                         Label="Add" />
                    <r:RibbonButton x:Name="btnSLEdit"

                                         SmallImageSource="/WpfRibbonApplication1;component/Images/Edit1.jpg"

                                         Label="Edit" />

                </r:RibbonGroup>
                <r:RibbonGroup x:Name="grpNCaptLog" >
                    <r:RibbonGroup.Background>
                        <RadialGradientBrush>
                            <GradientStop Color="Black" Offset="0" />
                            <GradientStop Color="White" Offset="1" />
                            <GradientStop Color="#FF38E538" Offset="0.006" />
                        </RadialGradientBrush>
                    </r:RibbonGroup.Background>
                    <r:RibbonButton x:Name="btnCLSearch"

                                         LargeImageSource="/WpfRibbonApplication1;component/Images/Capt_Log.ico"

                                         Label="Captains"

                                         Click="btnCLSearch_Click_1" />
                    <r:RibbonButton x:Name="btnCLAdd"

                                         SmallImageSource="/WpfRibbonApplication1;component/Images/Add-icon.png"

                                         Label="Add" />
                    <r:RibbonButton x:Name="btnCLEdit"

                                         SmallImageSource="/WpfRibbonApplication1;component/Images/Edit1.jpg"

                                         Label="Edit" />

                </r:RibbonGroup>
            </r:RibbonTab>
            <r:RibbonTab x:Name="tabTrip"

                          Header="Trip Planner" >
                <r:RibbonGroup x:Name="grpTPWayPoint">
                    <r:RibbonButton x:Name="btnWSearch"

                                         LargeImageSource="/WpfRibbonApplication1;component/Images/WayPoint-icon.png"

                                         Label="WayPoint" />
                    <r:RibbonGroup.Background>
                        <RadialGradientBrush>
                            <GradientStop Color="#FFDD81E5" Offset="0" />
                            <GradientStop Color="White" Offset="1" />
                        </RadialGradientBrush>
                    </r:RibbonGroup.Background>
                </r:RibbonGroup>
                <r:RibbonGroup x:Name="grpTrip" >
                    <r:RibbonButton x:Name="btnTSearch"

                                         LargeImageSource="/WpfRibbonApplication1;component/Images/TripPlanner.png"

                                         Label="Trip Planner" />
                    <r:RibbonGroup.Background>
                        <RadialGradientBrush>
                            <GradientStop Color="#FFDD81E5" Offset="0" />
                            <GradientStop Color="White" Offset="1" />
                        </RadialGradientBrush>
                    </r:RibbonGroup.Background>
                </r:RibbonGroup>
            </r:RibbonTab>
            <r:RibbonTab x:Name="tabLockers"

                          Header="Lockers" >
                <r:RibbonGroup x:Name="grpLEngine">
                    <r:RibbonButton x:Name="btnESearch"

                                         LargeImageSource="/WpfRibbonApplication1;component/Images/Engine.png"

                                         Label="Engine" />
                    <r:RibbonGroup.Background>
                        <RadialGradientBrush>
                            <GradientStop Color="#FFF82D15" Offset="0" />
                            <GradientStop Color="White" Offset="1" />
                        </RadialGradientBrush>
                    </r:RibbonGroup.Background>
                </r:RibbonGroup>
                <r:RibbonGroup x:Name="grpLSail" >
                    <r:RibbonButton x:Name="btnSSearch"

                                         LargeImageSource="/WpfRibbonApplication1;component/Images/Sailboat_button.png"

                                         Label="Sail" />
                    <r:RibbonGroup.Background>
                        <RadialGradientBrush>
                            <GradientStop Color="#FFF82D15" Offset="0" />
                            <GradientStop Color="White" Offset="1" />
                        </RadialGradientBrush>
                    </r:RibbonGroup.Background>
                </r:RibbonGroup>
                <r:RibbonGroup x:Name="grpLAccessories" >
                    <r:RibbonButton x:Name="btnASearch"

                                         LargeImageSource="/WpfRibbonApplication1;component/Images/Accessories.png"

                                         Label="Accessories" />
                    <r:RibbonGroup.Background>
                        <RadialGradientBrush>
                            <GradientStop Color="#FFF82D15" Offset="0" />
                            <GradientStop Color="White" Offset="1" />
                        </RadialGradientBrush>
                    </r:RibbonGroup.Background>
                </r:RibbonGroup>
                <r:RibbonGroup x:Name="grpLContacts" >
                    <r:RibbonButton x:Name="btnCSearch"

                                         LargeImageSource="/WpfRibbonApplication1;component/Images/Contacts.jpg"

                                         Label="Contacts" />
                    <r:RibbonGroup.Background>
                        <RadialGradientBrush>
                            <GradientStop Color="#FFF82D15" Offset="0" />
                            <GradientStop Color="White" Offset="1" />
                        </RadialGradientBrush>
                    </r:RibbonGroup.Background>
                </r:RibbonGroup>
                <r:RibbonGroup x:Name="grpLCrew">
                    <r:RibbonButton x:Name="btnLCSearch"

                                         LargeImageSource="/WpfRibbonApplication1;component/Images/Crew.gif"

                                         Label="Crew" />
                    <r:RibbonGroup.Background>
                        <RadialGradientBrush>
                            <GradientStop Color="#FFF82D15" Offset="0" />
                            <GradientStop Color="White" Offset="1" />
                        </RadialGradientBrush>
                    </r:RibbonGroup.Background>
                </r:RibbonGroup>
                <r:RibbonGroup x:Name="grpLVessels" >
                    <r:RibbonButton x:Name="btnVSearch"

                                         LargeImageSource="/WpfRibbonApplication1;component/Images/Wheel_button.png"

                                         Label="Vessels"

                                         Click="btnVSearch_Click" />
                    <r:RibbonGroup.Background>
                        <RadialGradientBrush>
                            <GradientStop Color="#FFF82D15" Offset="0" />
                            <GradientStop Color="White" Offset="1" />
                        </RadialGradientBrush>
                    </r:RibbonGroup.Background>
                </r:RibbonGroup>
                <r:RibbonGroup x:Name="grpLInsurance" >
                    <r:RibbonButton x:Name="btnISearch"

                                         LargeImageSource="/WpfRibbonApplication1;component/Images/LargeIcon.png"

                                         Label="Insurance" />
                    <r:RibbonGroup.Background>
                        <RadialGradientBrush>
                            <GradientStop Color="#FFF82D15" Offset="0" />
                            <GradientStop Color="White" Offset="1" />
                        </RadialGradientBrush>
                    </r:RibbonGroup.Background>
                </r:RibbonGroup>
            </r:RibbonTab>

            <r:RibbonTab x:Name="tabTools"

                              Header="Tools" >
                <r:RibbonGroup x:Name="grpTSafetyCheck" >
                    <r:RibbonGroup.Background>
                        <RadialGradientBrush>
                            <GradientStop Color="#FF9292F2" Offset="0" />
                            <GradientStop Color="#051E1EE8" Offset="0.965" />
                        </RadialGradientBrush>
                    </r:RibbonGroup.Background>
                    <r:RibbonButton x:Name="btnTSSearch"

                                         LargeImageSource="/WpfRibbonApplication1;component/Images/Life%20Ring.jpg"

                                         Label="Safety Check" />
                </r:RibbonGroup>
                <r:RibbonGroup x:Name="grpCalculators"

                                    Header="Calculators" >
                    <r:RibbonGroup.Background>
                        <RadialGradientBrush>
                            <GradientStop Color="#FF9292F2" Offset="0" />
                            <GradientStop Color="#051E1EE8" Offset="0.965" />
                        </RadialGradientBrush>
                    </r:RibbonGroup.Background>
                    <r:RibbonButton x:Name="btnNautical" Label="Nautical" />
                    <r:RibbonButton x:Name="btnStandard" Label="Standard" />
                    <r:RibbonButton x:Name="btnDMStoDD" Label="Convert DMS to DD" />
                </r:RibbonGroup>
                <r:RibbonGroup x:Name="grpSetUp" >
                    <r:RibbonGroup.Background>
                        <RadialGradientBrush>
                            <GradientStop Color="#FF9292F2" Offset="0" />
                            <GradientStop Color="#051E1EE8" Offset="0.965" />
                        </RadialGradientBrush>
                    </r:RibbonGroup.Background>
                    <r:RibbonButton x:Name="btnSetUp"

                                        LargeImageSource="/WpfRibbonApplication1;component/Images/YachtMaster_1.gif"

                                        Label="SetUp" />
                </r:RibbonGroup>
                <r:RibbonGroup x:Name="grpOptions" >
                    <r:RibbonGroup.Background>
                        <RadialGradientBrush>
                            <GradientStop Color="#FF9292F2" Offset="0" />
                            <GradientStop Color="#051E1EE8" Offset="0.965" />
                        </RadialGradientBrush>
                    </r:RibbonGroup.Background>
                    <r:RibbonButton x:Name="btnOptions"

                                        LargeImageSource="/WpfRibbonApplication1;component/Images/FlotPlan%201.gif"

                                        Label="Options" />
                </r:RibbonGroup>
            </r:RibbonTab>
            <r:Ribbon.QuickAccessToolBar >
                <r:RibbonQuickAccessToolBar >
                    <r:RibbonButton x:Name="btnQAT"

                                    Label="QAT button"

                                    Click="btnQAT_Click"

                                    SmallImageSource="/WpfRibbonApplication1;component/Images/PJS.ico" />
                    <r:RibbonButton x:Name="btnAbout"

                                    Label="About"

                                    Click="btnAbout_Click"

                                    SmallImageSource="/WpfRibbonApplication1;component/Images/Help.png" />
                </r:RibbonQuickAccessToolBar>
            </r:Ribbon.QuickAccessToolBar>
        </r:Ribbon>
        <DataGrid AutoGenerateColumns="False" EnableRowVirtualization="True" Height="200" ItemsSource="{Binding}" Margin="12,37,12,0" Name="vesselDetails_VDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" VerticalAlignment="Top" Grid.Row="1">
            <DataGrid.Columns>
                <DataGridTextColumn x:Name="vesselNameColumn" Binding="{Binding Path=VesselName}" Header="Vessel Name" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="vesselTypeColumn" Binding="{Binding Path=VesselType}" Header="Vessel Type" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="powerSailColumn" Binding="{Binding Path=PowerSail}" Header="Power Sail" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="v_RegistrationNumberColumn" Binding="{Binding Path=V_RegistrationNumber}" Header="V Registration Number" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="v_NumberEnginesColumn" Binding="{Binding Path=V_NumberEngines}" Header="V Number Engines" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="homePortColumn" Binding="{Binding Path=HomePort}" Header="Home Port" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="homePortCountryColumn" Binding="{Binding Path=HomePortCountry}" Header="Home Port Country" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="vCommColumn" Binding="{Binding Path=VComm}" Header="VComm" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="vManufactColumn" Binding="{Binding Path=VManufact}" Header="VManufact" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="vModelColumn" Binding="{Binding Path=VModel}" Header="VModel" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="vDesignerColumn" Binding="{Binding Path=VDesigner}" Header="VDesigner" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="vHullNumberColumn" Binding="{Binding Path=VHullNumber}" Header="VHull Number" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="hLOAColumn" Binding="{Binding Path=HLOA}" Header="HLOA" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="hLaWColumn" Binding="{Binding Path=HLaW}" Header="HLa W" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="hBeamColumn" Binding="{Binding Path=HBeam}" Header="HBeam" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="hMastColumn" Binding="{Binding Path=HMast}" Header="HMast" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="hBoomColumn" Binding="{Binding Path=HBoom}" Header="HBoom" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="hDraftColumn" Binding="{Binding Path=HDraft}" Header="HDraft" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="hKeelWtColumn" Binding="{Binding Path=HKeelWt}" Header="HKeel Wt" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="hDispColumn" Binding="{Binding Path=HDisp}" Header="HDisp" Width="SizeToHeader" />
                <DataGridCheckBoxColumn x:Name="defaultVesselColumn" Binding="{Binding Path=DefaultVessel}" Header="Default Vessel" Width="SizeToHeader" />
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</r:RibbonWindow>


-------------------------------------------------- ------------------------------
That said... when I place the exact same code inside a UserControl it fails to show any data? Here is the code from the UserControl...


--------------------------------------------------------------------------------
That said... when I place the exact same code inside a UserControl it fails to show any data? Here is the code from the UserControl...

<UserControl x:Class="WpfRibbonApplication1.Controls.ucVesselDetail"

             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

             mc:Ignorable="d"

             d:DesignHeight="516" d:DesignWidth="557" xmlns:my="clr-namespace:WpfRibbonApplication1.Controls" xmlns:my1="clr-namespace:WpfRibbonApplication1" Loaded="UserControl_Loaded">
    <UserControl.Resources>
        <my1:YachtLogPro_SQLDataSet x:Key="yachtLogPro_SQLDataSet" />
        <CollectionViewSource x:Key="vesselDetails_VViewSource" Source="{Binding Path=VesselDetails_V, Source={StaticResource yachtLogPro_SQLDataSet}}" />
    </UserControl.Resources>
    <Grid Height="508" DataContext="{Binding}">
        <Grid DataContext="{StaticResource vesselDetails_VViewSource}" Margin="120,18,0,0" Name="grid1" VerticalAlignment="Top">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Label Content="Vessel Name:" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <ComboBox DisplayMemberPath="VesselName" Grid.Column="1" Grid.Row="0" Height="23" HorizontalAlignment="Left" ItemsSource="{Binding}" Margin="3" Name="vesselNameComboBox" VerticalAlignment="Center" Width="120">
                <ComboBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <VirtualizingStackPanel />
                    </ItemsPanelTemplate>
                </ComboBox.ItemsPanel>
            </ComboBox>
            <Label Content="Vessel Type:" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="3" Name="vesselTypeTextBox" Text="{Binding Path=VesselType, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
            <Label Content="Power Sail:" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="2" Height="23" HorizontalAlignment="Left" Margin="3" Name="powerSailTextBox" Text="{Binding Path=PowerSail, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
            <Label Content="V Registration Number:" Grid.Column="0" Grid.Row="3" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="3" Height="23" HorizontalAlignment="Left" Margin="3" Name="v_RegistrationNumberTextBox" Text="{Binding Path=V_RegistrationNumber, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
            <Label Content="V Number Engines:" Grid.Column="0" Grid.Row="4" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="4" Height="23" HorizontalAlignment="Left" Margin="3" Name="v_NumberEnginesTextBox" Text="{Binding Path=V_NumberEngines, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
            <Label Content="Home Port:" Grid.Column="0" Grid.Row="5" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="5" Height="23" HorizontalAlignment="Left" Margin="3" Name="homePortTextBox" Text="{Binding Path=HomePort, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
            <Label Content="Home Port Country:" Grid.Column="0" Grid.Row="6" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="6" Height="23" HorizontalAlignment="Left" Margin="3" Name="homePortCountryTextBox" Text="{Binding Path=HomePortCountry, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
            <Label Content="VComm:" Grid.Column="0" Grid.Row="7" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="7" Height="23" HorizontalAlignment="Left" Margin="3" Name="vCommTextBox" Text="{Binding Path=VComm, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
            <Label Content="VManufact:" Grid.Column="0" Grid.Row="8" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="8" Height="23" HorizontalAlignment="Left" Margin="3" Name="vManufactTextBox" Text="{Binding Path=VManufact, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
            <Label Content="VModel:" Grid.Column="0" Grid.Row="9" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="9" Height="23" HorizontalAlignment="Left" Margin="3" Name="vModelTextBox" Text="{Binding Path=VModel, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
            <Label Content="VDesigner:" Grid.Column="0" Grid.Row="10" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="10" Height="23" HorizontalAlignment="Left" Margin="3" Name="vDesignerTextBox" Text="{Binding Path=VDesigner, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
            <Label Content="VHull Number:" Grid.Column="0" Grid.Row="11" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="11" Height="23" HorizontalAlignment="Left" Margin="3" Name="vHullNumberTextBox" Text="{Binding Path=VHullNumber, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
            <Label Content="HLOA:" Grid.Column="0" Grid.Row="12" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="12" Height="23" HorizontalAlignment="Left" Margin="3" Name="hLOATextBox" Text="{Binding Path=HLOA, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
            <Label Content="HLa W:" Grid.Column="0" Grid.Row="13" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="13" Height="23" HorizontalAlignment="Left" Margin="3" Name="hLaWTextBox" Text="{Binding Path=HLaW, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
            <Label Content="HBeam:" Grid.Column="0" Grid.Row="14" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="14" Height="23" HorizontalAlignment="Left" Margin="3" Name="hBeamTextBox" Text="{Binding Path=HBeam, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
            <Label Content="HMast:" Grid.Column="0" Grid.Row="15" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="15" Height="23" HorizontalAlignment="Left" Margin="3" Name="hMastTextBox" Text="{Binding Path=HMast, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
            <Label Content="HBoom:" Grid.Column="0" Grid.Row="16" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="16" Height="23" HorizontalAlignment="Left" Margin="3" Name="hBoomTextBox" Text="{Binding Path=HBoom, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
            <Label Content="HDraft:" Grid.Column="0" Grid.Row="17" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="17" Height="23" HorizontalAlignment="Left" Margin="3" Name="hDraftTextBox" Text="{Binding Path=HDraft, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
            <Label Content="HKeel Wt:" Grid.Column="0" Grid.Row="18" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="18" Height="23" HorizontalAlignment="Left" Margin="3" Name="hKeelWtTextBox" Text="{Binding Path=HKeelWt, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
            <Label Content="HDisp:" Grid.Column="0" Grid.Row="19" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="19" Height="23" HorizontalAlignment="Left" Margin="3" Name="hDispTextBox" Text="{Binding Path=HDisp, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
            <Label Content="Default Vessel:" Grid.Column="0" Grid.Row="20" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <CheckBox Content="" Grid.Column="1" Grid.Row="20" Height="16" HorizontalAlignment="Left" IsChecked="{Binding Path=DefaultVessel, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" Margin="3" Name="defaultVesselCheckBox" VerticalAlignment="Center" />
        </Grid>
    </Grid>
</UserControl>


-------------------------------------------------- --------------------
I hope this will help you understand my issue...
I believe that it is a conceptual one... the concept of putting data controls bound to a DataSet inside a UserControl?


----------------------------------------------------------------------
I hope this will help you understand my issue...
I believe that it is a conceptual one... the concept of putting data controls bound to a DataSet inside a UserControl?


这篇关于当放置在WPF MainWindow中时,UserControl中的DatagGrid不显示数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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