Help me I want to get the value of selectedValue in ListBox [modified]
-
How I can access to textblock in DataATemplate I want to get the value of selectedValue Here's the code
<Window x:Class="ElementsCloudTestVodafoneSeaWindow.VodafoneSeaWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:data="clr-namespace:ElementsCloudTestVodafoneUpper"
xmlns:cloud="clr-namespace:ElementsCloud;assembly=ElementsCloud"Title="Data Visualization" Width="640" Height="480" WindowState="Maximized"> <Window.Resources> <ObjectDataProvider x:Key="objDs" ObjectType="{x:Type data:CDataAccess}" MethodName="GetCites"> </ObjectDataProvider> <DataTemplate x:Key="BookTemplate"> <DataTemplate.Resources> <Storyboard x:Key="Storyboard1"> <ThicknessAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="stackPanel" Storyboard.TargetProperty="(FrameworkElement.Margin)"> <SplineThicknessKeyFrame KeyTime="00:00:00.5000000" Value="5,0,0,0"/> <SplineThicknessKeyFrame KeyTime="00:00:01" Value="20,0,20,0"/> </ThicknessAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="stackPanel" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)\[3\].(TranslateTransform.X)"> <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="7"/> <SplineDoubleKeyFrame KeyTime="00:00:01" Value="0"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="stackPanel" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)\[2\].(RotateTransform.Angle)"> <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="-33"/> <SplineDoubleKeyFrame KeyTime="00:00:01" Value="0"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="stackPanel" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)\[1\].(SkewTransform.AngleX)">
-
How I can access to textblock in DataATemplate I want to get the value of selectedValue Here's the code
<Window x:Class="ElementsCloudTestVodafoneSeaWindow.VodafoneSeaWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:data="clr-namespace:ElementsCloudTestVodafoneUpper"
xmlns:cloud="clr-namespace:ElementsCloud;assembly=ElementsCloud"Title="Data Visualization" Width="640" Height="480" WindowState="Maximized"> <Window.Resources> <ObjectDataProvider x:Key="objDs" ObjectType="{x:Type data:CDataAccess}" MethodName="GetCites"> </ObjectDataProvider> <DataTemplate x:Key="BookTemplate"> <DataTemplate.Resources> <Storyboard x:Key="Storyboard1"> <ThicknessAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="stackPanel" Storyboard.TargetProperty="(FrameworkElement.Margin)"> <SplineThicknessKeyFrame KeyTime="00:00:00.5000000" Value="5,0,0,0"/> <SplineThicknessKeyFrame KeyTime="00:00:01" Value="20,0,20,0"/> </ThicknessAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="stackPanel" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)\[3\].(TranslateTransform.X)"> <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="7"/> <SplineDoubleKeyFrame KeyTime="00:00:01" Value="0"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="stackPanel" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)\[2\].(RotateTransform.Angle)"> <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="-33"/> <SplineDoubleKeyFrame KeyTime="00:00:01" Value="0"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="stackPanel" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)\[1\].(SkewTransform.AngleX)">
Somewhere in that HUGE code dump there should be an itemssource={binding observablecollection} and a selecteditem={binding SelectedObject}. The selectedobject then has the information you are looking for, wherever possible use the data container to manipulate your information, NOT your display object. I do wonder why you used a listbox instead of a gridview, so far I have not ever had to use a listbox.
Never underestimate the power of human stupidity RAH