Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have prepared a view in which there is a ListView Control whose ItemSource is being populated with the XML data.However along with the XML data I also required to have a check box and 2 textboxes which takes two different values.

What I have tried:

The view has been achieved with the below xaml code.
XML
<Window.Resources>
        <!--XML Data Source-->
        <XmlDataProvider x:Key="InstrumentList" Source="Instrumentlist.xml"/>
    </Window.Resources>
    <Grid>

        <ListView Height="153" 
              HorizontalAlignment="Left" 
              Name="listView1" 
              VerticalAlignment="Top" 
              Width="503"
              ItemsSource="{Binding Source={StaticResource InstrumentList}, XPath=instrument/instruments}">
            <ListView.View>
                <GridView>
                    <GridView.Columns>
                        <GridViewColumn x:Name="g1" >
                            <GridViewColumn.HeaderTemplate>
                                <DataTemplate >
                                    <CheckBox x:Name="checkall" />
                                </DataTemplate>
                            </GridViewColumn.HeaderTemplate>
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <CheckBox IsChecked="False"/>

                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn  Header="Instrref" />
                        <GridViewColumn Width="120" Header="OrderLimit">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBox Name="txt_OrderLimit" Width="100"/>

                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Width="120" Header="ValueLimit">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBox Name="txt_ValueLimit" Width="100"/>

                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>

                    </GridView.Columns>


                </GridView>
            </ListView.View>
        </ListView>
        <Button x:Name="button" Content="Submit" HorizontalAlignment="Left" Margin="0,174,0,0" VerticalAlignment="Top" Width="194" Click="button_Click"/>


    </Grid>
</Window>



My Xml file content:

XML
<?xml version="1.0" encoding="utf-8" ?>
<instrument>

  <instruments>
  <instrument_reference>NIFTY12SEP8700CE</instrument_reference>
  </instruments>
  <instruments>
  <instrument_reference>NIFTY12SEP8600CE</instrument_reference>
  </instruments>
  <instruments>
  <instrument_reference>NIFTY12SEP8900CE</instrument_reference>
  </instruments>
  <instruments>
    <instrument_reference>NIFTY12SEP9000CE</instrument_reference>
  </instruments>
  <instruments>
    <instrument_reference>NIFTY12SEP9100CE</instrument_reference>
  </instruments>
  <instruments>
    <instrument_reference>NIFTY12SEP9200CE</instrument_reference>
  </instruments>
</instrument>



Now what I want to achieve is when I checks multiple rows and simultaneouly put some values in the text box then I should be able to store data somewhere only for the checked rows-Instrumentref,textbox1 value,textbox2 value.

I am new to the WPF and finding very difficult to access the values.Please help
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900