tags:

views:

39

answers:

0

Hi

I am trying to create a data maintenance window. A former developer created a "dataservice" application using web services. It stores a string of values that gets converted to SQL (done this way to allow for independent queries). The UI is being developed in Visual Studio 2008 using .NET 3.5.

The screen I am working on at the moment needs to show a list of data tables assoicated with a data set (this is our dataset/datatable, not VS before anyone gets confused). The relationships are complicated. We have a client and a Data Set. Each Data set has one or more tables and each data set table has one or more columns. Join tables allow each client to have their own version of the "schema" - i.e. ClientDataSet and ClientDataSetTable etc...

The DataSetTable maintenance screen needs to allow the user to view all tables linked to a dataset and add a new table to the selected data set. Since there are multiple datasets, I planned to use a master detail relationship. A combobox would list all available datasets. When a dataset is selected, a list box would show the associated tables for that dataset. Selecting a table in the listbox would display the properties alongside.

Since I cannot post an image, I will try to mark it up in text

    DataSet:      <DataSetComboBox>

    =============      TableID:        <Read Only Field>
    |           |      TableName:      <TextBox>
    | ListBox   |      Is Snapshotted: <ChexkBox>
    |           |
    |           |
    |           |
    |           |
    |           |
    =============
<Add Table Button>    <OK Button>  <Cancel Button>  <Apply Button>

I have been using Data binding on other screens with reasonable success. However, this requires me to use two data sources. I know I could just assign in the code behind, but how do you do this using XAML?

<Window x:Class="ABC_Data_Service_UI.Windows.DataSetTablesMaint"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:System="clr-namespace:System;assembly=mscorlib"
Title="DataSetTablesMaint"  Height="447" Width="548" Name="windowDataSetTables" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" WindowStyle="SingleBorderWindow">
<Window.Resources>
    <System:Boolean x:Key="ApplyEnabled"></System:Boolean>
</Window.Resources>
<Canvas Height="406" DataContext="{Binding}">
    <Button Name="buttonOK" IsDefault="True" Click="buttonOK_Click" Height="21" Canvas.Left="254" Canvas.Top="362" Width="75">OK</Button>
    <Button Name="buttonCancel" IsCancel="True" Click="buttonCancel_Click" Height="21" Canvas.Left="335" Canvas.Top="362" Width="75">Cancel</Button>
    <Button Name="buttonApply" Click="buttonApply_Click" Width="75" Canvas.Top="362" Height="21" Canvas.Left="416" IsEnabled="{Binding Path=Status}">Apply</Button>
    <StackPanel Canvas.Left="0" Canvas.Top="39" Height="317" Name="stackPanelDivider" Width="491" Orientation="Horizontal" Margin="2,2,2,2">
        <ListBox Height="305" Name="listBoxDataSetTables" Width="199" 
                 ItemsSource="{Binding}" 
                 SelectedValue="TableID"
                 DisplayMemberPath="TableName" 
                 IsSynchronizedWithCurrentItem="False"
                 SelectionChanged="listBoxDataSetTables_SelectionChanged"
                 Loaded="listBoxDataSetTables_Loaded"/>
        <Grid Height="Auto" Name="gridProperties" Width="291" VerticalAlignment="Top" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="2*" />
                <ColumnDefinition Width="5*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Label Name="labelTableID"   Grid.Row="0" Grid.Column="0">Table ID:</Label>
            <Label Name="labelTableName"   Grid.Row="2" Grid.Column="0">Table Name:</Label>
            <Label Name="labelIsSnapshotted"     Grid.Row="4" Grid.Column="0">Is Snapshotted</Label>
            <TextBox Name="textBoxTableID"   Grid.Row="0" Grid.Column="1" Margin="2" SnapsToDevicePixels="True" Text="{Binding Path=DataSetID}" Background="LightGray" IsReadOnly="True"></TextBox>
            <TextBox Name="textBoxTableName"   Grid.Row="2" Grid.Column="1" Margin="2" SnapsToDevicePixels="True" Text="{Binding Path=Namespace}" TextChanged="PropertyChanged"></TextBox>
            <CheckBox Name="checkBoxIsSnapshotted"   Grid.Row="4" Grid.Column="1" Margin="2,5,0,0" HorizontalAlignment="Left" SnapsToDevicePixels="True" IsChecked="{Binding Path=IsSnapshotted}" Checked="PropertyChanged"></CheckBox>
        </Grid>
    </StackPanel>
    <Button Canvas.Left="0" Canvas.Top="362" Height="23" Name="buttonAddDataSetTable" Width="75" Click="buttonAddDataSetTable_Click" IsEnabled="{Binding Path=Status}">Add Table</Button>
    <Label Canvas.Left="2" Canvas.Top="7" Height="Auto" Name="labelDataSet" Width="65">DateSet:</Label>
    <ComboBox Canvas.Left="73" Canvas.Top="12" Height="Auto" Name="comboBoxDataSet" Width="179" />
</Canvas>