Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
380
selectedvalue not displaying
posted

Hi..I am using Listview for display data.it works fine.

But i want the listview selected item value in one variable.i m trying to retrieve using selectedvalue property.but its taking null value.

if the user selects one cell value in the listview then he clicks the button then tat value sholud be displayed in messgebox.

can u suggest some answer for this.

My listview is as shown below.

<ListView ItemsSource="{Binding}" x:Name="ListView1"

 

 

DisplayMemberPath="{Binding}"

 

 

 

DataContext="{Binding Source={StaticResource BookProvider1}}"

 

 

IsSynchronizedWithCurrentItem="True" Margin="369,135,38,46">

 

 

<ListView.ItemContainerStyle><Style TargetType="ListViewItem">

 

 

<Setter Property="HorizontalContentAlignment" Value="Stretch" />

 

 

<EventSetter Event="GotFocus" Handler="Item_GotFocus" />

 

 

</Style>

 

 

</ListView.ItemContainerStyle>

 

 

 

<ListView.View>

 

 

<GridView>

 

 

<GridViewColumn Header="BookID" Width="100" x:Name="Col"

 

 

DisplayMemberBinding="{Binding Path=BookId,Mode=OneWay}">

 

 

<GridViewColumn.CellTemplate>

 

 

<DataTemplate>

 

 

<TextBox Text="{Binding Path=BookId,Mode=OneWay}"

 

 

 

Margin="-6,0,-6,0"/>

 

 

</DataTemplate>

 

 

</GridViewColumn.CellTemplate>

 

 

</GridViewColumn>

 

 

 

<GridViewColumn Header="BookName" Width="100"

 

 

DisplayMemberBinding="{Binding Path=BookName,Mode=TwoWay}">

 

 

<GridViewColumn.CellTemplate>

<DataTemplate>

<TextBox Text="{Binding Path=BookName,Mode=TwoWay}"

Margin="-6,0,-6,0"/>

</DataTemplate>

</GridViewColumn.CellTemplate>

 

 

</GridViewColumn>

 

 

 

<GridViewColumn Header="BookDescription" Width

="200"

 

 

DisplayMemberBinding="{Binding Path=BookDesc,Mode

=TwoWay}">

 

 

<GridViewColumn.CellTemplate>

<DataTemplate>

<TextBox Text="{Binding Path=BookDesc,Mode=TwoWay}"

Margin="-6,0,-6,0"/>

</DataTemplate>

</GridViewColumn.CellTemplate>

 

 

</GridViewColumn>

 

 

</GridView>

 

 

</ListView.View>

 

 

</ListView>

Please how to retrieve this listview selected value ..because here in listview i m placing gridview.

how to select that gridview cell selected value..

Please give answer for this..because i m new to wpf..

Thanks in advance..