Autor Beitrag
csharpuser1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 51



BeitragVerfasst: Mi 21.12.16 16:10 
Hi,

ich habe ein Tab Control. Jeder Tab ist ein User Control mit verschiedenen Elementen. In einem Tab habe ich ein GridView. Dies soll einen Header Namen und einen Funktion enthalten.

Nun klappt der erste Schritt, nachdem in einem anderen Tab die Namen gefüllt wurden, diese hier einzufügen mithilfe eines Bindings.

Die Combobox funktioniert aber nicht. Es erscheint nichtmal eine Combobox, einfach nur ein leeres Feld an der Stelle.


Hier Code:

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
<UserControl x:Class="Tab_Control.AddPin"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="400" d:DesignWidth="700">
    <Grid>
        <DataGrid Name="PadNames" AutoGenerateColumns="False" HorizontalAlignment="Left" Width="283">
            <DataGrid.Columns>
                <DataGridTextColumn x:Name="PinNames" Header="PinNames" Binding="{Binding PadName}" />
                <DataGridComboBoxColumn Header="SelectedFunktion" Width="100" x:Name="Funktionen" 
                    SelectedValueBinding="{Binding Funktionen, Mode=TwoWay}"  
                    DisplayMemberPath="{Binding Funktionen}" />
            </DataGrid.Columns>
        </DataGrid>
           </Grid>
</UserControl>


ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
using System.Collections.Generic;
public class AddPadCatalogue
{

    public string PadName { get; set; }

    public List<string> Funktionen { get; set; }

}


ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
    public partial class AddPin : UserControl
    {
        public List<string> Functions { get; set; }

        public AddPin()
        {
            InitializeComponent();
        }

        public void jointab_AddPin()
        {

            Functions = new List<string>();
            Functions.Add("Male");
            Functions.Add("Female");

            ObservableCollection<AddPadCatalogue> PadCatalogue = new ObservableCollection<AddPadCatalogue>();

            for (int i = 0; i < PortFunctions.exceptionPFs.Count; i++)
            {

                PadCatalogue.Add(new AddPadCatalogue() { PadName = Pads.AddablePads[i], Funktionen=Functions });
            }

            
            PadNames.ItemsSource = PadCatalogue;
            Funktionen.ItemsSource = Functions;

        }

    }
csharpuser1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 51



BeitragVerfasst: Mi 21.12.16 16:59 
Was ich herausgefunden habe:

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
        public AddPin()
        {
            

        }

        public void jointab_AddPin()
        {
            Employees = new List<Employee>();

            for (int i = 0; i < 10; i++)
            {
                Employees.Add(new Employee() { Name = i.ToString() });
            }


            Genders = new List<string>();
            Genders.Add("Male");
            Genders.Add("Female");

            InitializeComponent();
            myGrid.ItemsSource = Employees;

            Gender.ItemsSource = Genders;
        }



JoinTab wird aufgerufen, wenn ich in den Tab reingehe. Es funktioniert, wenn ich alles was in JoinTab steht, in den Konstruktor packe. Wenn ich es so ausführe erscheint das DataGrid genauso, nur ohne Comboboxen!!!




Warum zur Hölle?
csharpuser1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 51



BeitragVerfasst: Mi 21.12.16 17:21 
Lösung:

Das GridView Selection Changed generieren mit e.Handled = true ...

Moderiert von user profile iconTh69: C#-Tags hinzugefügt