0

I have a list of data which is bind to a combobox, so each item in combobox has three different set of data. Here is my data:

Private Class PhotoType
        Public Property FrameDimension() As Integer()
        Public Property InnerFrameMargin() As Integer() '{top, bottom, left, right}
        Public Property InnerFramePosition() As Integer() '{xpos, ypos}
        Public Property PhotoData() As List(Of Integer())
    End Class

Public Function PhotoList()
    Dim listPhoto As New List(Of PhotoType) From {
        '------------ Item 1 --------------
        New PhotoType With {
            .FrameDimension = {60, 90},
            .InnerFrameMargin = {10, 30, 10, 10},
            .InnerFramePosition = {5, -5}},
       '------------ Item 2 --------------
        New PhotoType With {
            .FrameDimension = {60, 90},
            .InnerFrameMargin = {5, 5, 5, 5},
            .InnerFramePosition = {5, -5}}
    }
    PhotoList = listPhoto
End Function

On my code behind, here is my code:

Private Sub DockerPolaroid_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded
    With cb_layout
        .SelectedValuePath = "PhotoData"
        .ItemsSource = ClsData.PhotoList
    End With
End Sub

So I need to merge three arrays into one data so they can be put in SelectedValuePath in the code behind WPF form. I made a list variable called photodata to hold all those data, but I'm not sure what's the right approach for this. Should I just store the data in one array for this to work?

Ran_TH
  • 101
  • 1
  • 9
  • See this, https://stackoverflow.com/questions/59217/merging-two-arrays-in-net –  Sep 04 '18 at 03:29
  • 1
    You should provide a getter for that property that combines the data as you desire and returns it. It's completely up to you what you put in that getter. It basically a method so implement it like any other method. – jmcilhinney Sep 04 '18 at 03:31
  • @Richard: Yeah I seen that. So I guess that's no different than making one big array in my case. I thought there are other ways to make SelectedValuePath to take multiple variables. I'll consider it. – Ran_TH Sep 04 '18 at 03:31
  • @jmcilhinney could you elaborate more? I used your method in my previous question here: https://stackoverflow.com/questions/51471608/managing-values-of-data-within-a-wpf-combo-box-items It works great if I only refer to one property for the data but I'm not sure how to merge multiple properties so I can fit it in SelectedValuePath. – Ran_TH Sep 12 '18 at 07:35
  • Of course you know how to combine multiple properties. You add them, subtract them, multiply them, divide them, concatenate them or whatever else you want to do. Do that in the getter of the one property you bind to. Are you really telling me that you can't write a method that combines multiple values and returns the result? – jmcilhinney Sep 12 '18 at 07:42

0 Answers0