Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

wpf question

$
0
0

I am missing something?  I am just now trying to learn WPF coming from windows forms.  All my development  uses data from our production system.  I created a main window and placed 3 buttons and a list box and datagrid.  I populate them both when pressing a button.  The problem I have is the list box and the grid contain the results of 2 (both) different queries.  I select 10 items from the products tables in adventure works and I populate the datagrid with all the customers.  My query results for the grid are placed into a datatable then then returned as a dataview to populate the Datagrid's ItemSource.  My query for the list box take the first ten items from the Products tables and populates the list box.  Depending on which is populated first, the datagrid and the list box both contain over 18000 entries and the datagrid has the columns from the product table.  What am I doing wrong?  I am testing this and trying to learn how this is working.  I have no problem doing this in Windows Forms but I am having a problem understanding how the controls are doing this.

listBox1.ItemsSource = mytest.getData()

"Select top 10  EnglishProductName,color  from DimProduct" is the sql in my dbclass that returns a List<string>

dataGrid1.ItemsSource = mytest.getDataTableView();

"Select * from DimCustomer" is my sql place in a datable and return as a DataView;

Why do both controls contain both query results??  What am i missing??

Main window XAML

<Window x:Class="WyattWPFData.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="445" Width="525" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:my="clr-namespace:WyattWPFData" >
    <Window.Resources>
      
    </Window.Resources>
    <Grid Height="409" Width="504">
        <Grid.RowDefinitions>
            <RowDefinition Height="192*" />
            <RowDefinition Height="217*" />
        </Grid.RowDefinitions>
        <Grid Height="361" HorizontalAlignment="Left" Margin="23,12,0,0" Name="grid1" VerticalAlignment="Top" Width="459" Grid.RowSpan="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="73*" />
                <RowDefinition Height="113*" />
                <RowDefinition Height="175*" />
            </Grid.RowDefinitions>
            <Button Content="close" Height="23" HorizontalAlignment="Left" Margin="366,6,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
            <Button Content="Button" Height="23" HorizontalAlignment="Right" Margin="0,6,115,0" Name="button2" VerticalAlignment="Top" Width="75" Click="button2_Click" />
            <Button Content="Get Data" Height="23" HorizontalAlignment="Left" Margin="172,6,0,0" Name="button3" VerticalAlignment="Top" Width="75" Click="button3_Click" />
            <ListBox Grid.Row="1" Height="79" HorizontalAlignment="Left" Margin="110,11,0,0" Name="listBox1" VerticalAlignment="Top" Width="225" SelectionChanged="listBox1_SelectionChanged" />
            <DataGrid Height="160" HorizontalAlignment="Left" Margin="68,15,0,0" Name="dataGrid1" VerticalAlignment="Top" Width="383"
                      CurrentCellChanged="dataGrid1_CurrentCellChanged" SelectionChanged="dataGrid1_SelectionChanged" AutoGenerateColumns="True" SelectionMode="Extended" SelectionUnit="Cell" CellEditEnding="dataGrid1_CellEditEnding" BeginningEdit="dataGrid1_BeginningEdit" Grid.Row="2" />
      
                <Slider Height="228" HorizontalAlignment="Left" Margin="14,64,0,0" Name="slider1" VerticalAlignment="Top" Width="34" Value="{Binding ElementName=textBox1, Path=Text, StringFormat=\{0:N4\}}" Orientation="Vertical" Maximum="4" SmallChange="0.001" DataContext="{Binding}" Minimum="0.001" Grid.RowSpan="3" />
            <TextBox Height="23" HorizontalAlignment="Left" Margin="92,9,0,0" Name="textBox1" VerticalAlignment="Top" Width="50" Text="{Binding ElementName=slider1, Path=Value, StringFormat=\{0:N4\}}"></TextBox>
          
        </Grid>
    </Grid>
</Window>


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>