Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Help me I want to get the value of selectedValue in ListBox [modified]

Help me I want to get the value of selectedValue in ListBox [modified]

Scheduled Pinned Locked Moved WPF
dotnetwpfcomhostingcloud
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Honeyboy_20
    wrote on last edited by
    #1

    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)">
    
    M 1 Reply Last reply
    0
    • H Honeyboy_20

      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)">
      
      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups