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. WCF and WF
  4. how to access control located in listview.view from the code behid file

how to access control located in listview.view from the code behid file

Scheduled Pinned Locked Moved WCF and WF
csstutorial
5 Posts 3 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.
  • F Offline
    F Offline
    Feras Mazen Taleb
    wrote on last edited by
    #1

    I have a winow contain a list view with code like this

    <ListView Grid.Row="1" Name="FilterListView">
    <ListView.View>
    <GridView>
    <GridView.Columns>
    <GridViewColumn Header="Property Name" Width="210">
    <GridViewColumn.CellTemplate>
    <DataTemplate>
    <Grid>
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width="55" />
    <ColumnDefinition Width="150" />
    </Grid.ColumnDefinitions>
    <StackPanel Orientation="Horizontal">
    <TextBlock Name="txtBlock" Visibility="Collapsed" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" >Filter by :</TextBlock>
    <ComboBox Name="cmbMatchCondition" Visibility="Visible" Grid.Column="0" Width="50" Margin="1" SelectedIndex="0">
    <ComboBoxItem>And</ComboBoxItem>
    <ComboBoxItem>Or</ComboBoxItem>
    </ComboBox>
    </StackPanel>
    <ComboBox Name="cmbPropertyName" Grid.Column="1" Margin="1">
    </ComboBox>
    </Grid>
    </DataTemplate>
    </GridViewColumn.CellTemplate>
    </GridViewColumn>

                        <GridViewColumn Header="Condition"  Width="150">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel>
                                        <ComboBox Name="cmbCondition" Margin="1" SelectedIndex="0">
                                            <!--<ComboBoxItem>Equal</ComboBoxItem>
                                            <ComboBoxItem>Not Equal</ComboBoxItem>
    
    B 1 Reply Last reply
    0
    • F Feras Mazen Taleb

      I have a winow contain a list view with code like this

      <ListView Grid.Row="1" Name="FilterListView">
      <ListView.View>
      <GridView>
      <GridView.Columns>
      <GridViewColumn Header="Property Name" Width="210">
      <GridViewColumn.CellTemplate>
      <DataTemplate>
      <Grid>
      <Grid.ColumnDefinitions>
      <ColumnDefinition Width="55" />
      <ColumnDefinition Width="150" />
      </Grid.ColumnDefinitions>
      <StackPanel Orientation="Horizontal">
      <TextBlock Name="txtBlock" Visibility="Collapsed" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" >Filter by :</TextBlock>
      <ComboBox Name="cmbMatchCondition" Visibility="Visible" Grid.Column="0" Width="50" Margin="1" SelectedIndex="0">
      <ComboBoxItem>And</ComboBoxItem>
      <ComboBoxItem>Or</ComboBoxItem>
      </ComboBox>
      </StackPanel>
      <ComboBox Name="cmbPropertyName" Grid.Column="1" Margin="1">
      </ComboBox>
      </Grid>
      </DataTemplate>
      </GridViewColumn.CellTemplate>
      </GridViewColumn>

                          <GridViewColumn Header="Condition"  Width="150">
                              <GridViewColumn.CellTemplate>
                                  <DataTemplate>
                                      <StackPanel>
                                          <ComboBox Name="cmbCondition" Margin="1" SelectedIndex="0">
                                              <!--<ComboBoxItem>Equal</ComboBoxItem>
                                              <ComboBoxItem>Not Equal</ComboBoxItem>
      
      B Offline
      B Offline
      BlitzPackage
      wrote on last edited by
      #2

      First, in order to access any control it must be named. Second, given the visual tree of the txtBlock, it seems you will have to walk that visual tree until you get access to the element you want. I do think you will have to name all of the controls in order to easily facilitate that process. For example, txtBlock is located within a StackPanel that doesn't have a name. Hope this helps.

      S F 2 Replies Last reply
      0
      • B BlitzPackage

        First, in order to access any control it must be named. Second, given the visual tree of the txtBlock, it seems you will have to walk that visual tree until you get access to the element you want. I do think you will have to name all of the controls in order to easily facilitate that process. For example, txtBlock is located within a StackPanel that doesn't have a name. Hope this helps.

        S Offline
        S Offline
        sivaddrahcir
        wrote on last edited by
        #3

        Here is another possibility? For txtBlock, hook up a handler for the Loaded event and in the code-behind keep track of TextBlock objects that are passed in as sender parameters. This is what I mean exactly: Your TextBlock definition with Loaded event handler added:

        <TextBlock Name="txtBlock" Loaded="txtBlock_Loaded" Visibility="Collapsed" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" >Filter by :</TextBlock>

        And add something like this to the code-behind:

        Dictionary<int, TextBlock> txtBlockLookup;
        int txtBlockCount = 0;

        private void txtBlock_Loaded(object sender, RoutedEventArgs e)
        {
        if (txtBlockCount == 0)
        { txtBlockLookup = new Dictionary<int, TextBlock>(); }

        if (!txtBlockLookup.ContainsKey(txtBlockCount))
        {
            txtBlockLookup.Add(txtBlockCount++, sender as TextBlock);
        }
        

        }

        Blog: http://windowsclientdevelopment.spaces.live.com FAQs: http://windowspresentationfoundation.wikispaces.com http://windowsmobile.wikispaces.com http://vsto.wikispaces.com

        modified on Wednesday, March 25, 2009 6:52 PM

        F 1 Reply Last reply
        0
        • B BlitzPackage

          First, in order to access any control it must be named. Second, given the visual tree of the txtBlock, it seems you will have to walk that visual tree until you get access to the element you want. I do think you will have to name all of the controls in order to easily facilitate that process. For example, txtBlock is located within a StackPanel that doesn't have a name. Hope this helps.

          F Offline
          F Offline
          Feras Mazen Taleb
          wrote on last edited by
          #4

          just thanks a lot

          You have To Search About The Truth Of Your Life Why Are you Here In Life ?

          1 Reply Last reply
          0
          • S sivaddrahcir

            Here is another possibility? For txtBlock, hook up a handler for the Loaded event and in the code-behind keep track of TextBlock objects that are passed in as sender parameters. This is what I mean exactly: Your TextBlock definition with Loaded event handler added:

            <TextBlock Name="txtBlock" Loaded="txtBlock_Loaded" Visibility="Collapsed" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" >Filter by :</TextBlock>

            And add something like this to the code-behind:

            Dictionary<int, TextBlock> txtBlockLookup;
            int txtBlockCount = 0;

            private void txtBlock_Loaded(object sender, RoutedEventArgs e)
            {
            if (txtBlockCount == 0)
            { txtBlockLookup = new Dictionary<int, TextBlock>(); }

            if (!txtBlockLookup.ContainsKey(txtBlockCount))
            {
                txtBlockLookup.Add(txtBlockCount++, sender as TextBlock);
            }
            

            }

            Blog: http://windowsclientdevelopment.spaces.live.com FAQs: http://windowspresentationfoundation.wikispaces.com http://windowsmobile.wikispaces.com http://vsto.wikispaces.com

            modified on Wednesday, March 25, 2009 6:52 PM

            F Offline
            F Offline
            Feras Mazen Taleb
            wrote on last edited by
            #5

            thanks a lot it is a pretty good idea i will try it and tell you what I gain . :)

            You have To Search About The Truth Of Your Life Why Are you Here In Life ?

            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