The following is my Xaml code:
<Window x:Class="RadControlsWpfApp1.MainWindow" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" Title="MainWindow" Height="700" Width="900" Background="Black"> <Grid> <Grid.Resources> <DataTemplate x:Key="customItemTemplate"> <StackPanel> <Image Source="{Binding Path=Country}" Height="150" HorizontalAlignment="Left" Margin="10,10,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="200" /> <Button Content="Show Details" Height="23" Name="btnDetail" Width="75" Foreground="White" Click="btnDetail_Click" /> <Label x:Name="ID" Content="{Binding Path=ID}"></Label> </StackPanel> </DataTemplate> </Grid.Resources> <telerik:RadCarousel x:Name="sampleRadCarousel" ItemTemplate="{StaticResource customItemTemplate}" Background="Transparent" GotFocus="sampleRadCarousel_GotFocus" /> </Grid> </Window>I wanna show content of Lable (ID) when the user clicks to Button (btnDetail).
How can I do that?
Thanks for your helping.
6 Answers, 1 is accepted
You may get any item in RadCarousel cast it to your object and then you may access any properties you need. For example: you can get the Employee's Age of the SelectedItem in RadCarousel as follows:
private void RadButton_Click(object sender, RoutedEventArgs e) { var item = (this.carousel.SelectedItem as Employee).Age.ToString(); MessageBox.Show("Selected employee is " + item + " years old"); }You may read more about RadCarousel/WPF in our online documentation, following this link.
All the best,
Vanya Pavlova
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
So, the codes that you mentioned aren't suitable to my project.
Please look at:
OleDbConnection oleCon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=DataBase.mdb");OleDbCommand oleComd = new OleDbCommand("Select * From tblMovie", oleCon);DataSet dtst = new DataSet();OleDbDataAdapter adpt = new OleDbDataAdapter();oleCon.Open();adpt.SelectCommand = oleComd;adpt.Fill(dtst, "emp");sampleRadCarousel.ItemsSource = dtst.Tables[0].DefaultView;In this way how can I access the selected Item's value?
Thanks again.
Since you are binding to DataRows you have to gather the information from this row relatively to the RadCarousel's SelectedItem as demonstrated in the following MSDN article.
Vanya Pavlova
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
I tried so much and now I'm completely confused!
I saw MSDN article solution and tried to do that but in my project it returns Null.
Here is my code:
private void btnDetail_Click(object sender, RoutedEventArgs e) { object Obj = this.sampleRadCarousel.SelectedItem; DataRow Row = ((DataRowView)Obj).Row; MessageBox.Show("Selected ID is " + Row["ID"].ToString()); }
I have just tested the behavior when the RadCarouselPanel is bound to a DataTable and the snipper above works correctly by my side. I am attaching you the application which I used for testing. You may also submit a new support ticket and attach your project where we can see what might be wrong.
Vanya Pavlova
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
Thank you very much.
Have a good time.