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. How to use same usercontrol multiple time in the silverlight

How to use same usercontrol multiple time in the silverlight

Scheduled Pinned Locked Moved WPF
wpfwinformstutorialquestion
3 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.
  • N Offline
    N Offline
    Nekkantidivya
    wrote on last edited by
    #1

    Hi, I am working on a silverlight application. In this I need to place usercontrols on a canvas in the Page.xaml page dynamically at run time. Later I need to set the data values for the datagrid on these user controls from the Page.xaml itself. I want to set different data for different user controls. How can i differentiate these user controls from one another and set differnt data to their datagrid from Page.xaml itself. please reply me if u have any idea to solve this. Thanks in advance

    P J 2 Replies Last reply
    0
    • N Nekkantidivya

      Hi, I am working on a silverlight application. In this I need to place usercontrols on a canvas in the Page.xaml page dynamically at run time. Later I need to set the data values for the datagrid on these user controls from the Page.xaml itself. I want to set different data for different user controls. How can i differentiate these user controls from one another and set differnt data to their datagrid from Page.xaml itself. please reply me if u have any idea to solve this. Thanks in advance

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      There are a couple of ways to do this; it just depends on whether or not you are using pure databinding and MVVM. If you are using MVVM and pure databinding, then there's very little that you need to do because the View/ViewModel integration will take care of the hard work for you. If you aren't, then you can assign a name to each control when you assign it using the x:Name property, e.g. x:Name="myUserControl1" (this is if you add it into the XAML). If you add it using code behind, you just assign the name to the Name property.

      "WPF has many lovers. It's a veritable porn star!" - Josh Smith

      As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

      My blog | My articles | MoXAML PowerToys | Onyx

      1 Reply Last reply
      0
      • N Nekkantidivya

        Hi, I am working on a silverlight application. In this I need to place usercontrols on a canvas in the Page.xaml page dynamically at run time. Later I need to set the data values for the datagrid on these user controls from the Page.xaml itself. I want to set different data for different user controls. How can i differentiate these user controls from one another and set differnt data to their datagrid from Page.xaml itself. please reply me if u have any idea to solve this. Thanks in advance

        J Offline
        J Offline
        Jeremy Likness
        wrote on last edited by
        #3

        Either you are instantiating the objects yourself, and can take them with x:Name and have your own reference, or you are using them in a template in the DataGrid. If you are using them in a template, you can hook into the Loaded event and do something with them. For example, you might do this:

        <DataGrid>...<u:MyControl Loaded="MyControl_Loaded".../>...</DataGrid>

        In the MyControl_Loaded you can then take the event arguments and do something with the control, either processing, passing it into a controller, etc.

        Jeremy Likness Latest Article: Whats in Your Collection? Part 1 of 3: Interfaces Blog: C#er : IMage

        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