comboboxitem zichtbaar laten maken

Status
Niet open voor verdere reacties.

softwareboy

Gebruiker
Lid geworden
14 aug 2008
Berichten
89
Ik weet niet of dit het gepast forum is want het is namelijk in XAML in plaats van XML maar het schijnt dat deze twee dicht bij elkaar liggen. Dus hier m'n vraag:

Ik heb in een pagina 2 combobox'en met elk hun eigen comboboxitems. In combobox2 staan de comboboxitems onzichtbaar omdat er slechts een bepaald aantal mogen zichtbaar komen naar gelang welk item is aangeduid in combobox1. Het is dus de bedoeling als je bv. comboboxitem1 selecteert en drukt op de knop dat comboboxitem9 zichtbaar wordt in combobox2.

Weet iemand hoe ik dit moet doen want ik zit echt vast.:confused:

Ik doe dit met het programma Visual Studio 2010
Het is een Visual Basic Silverlight Applicatie
 
Laatst bewerkt:
kenk xaml niet maar kan je wat code uploade?
 
In XAML kun je door code te schrijven je form ontwerpen maar kun je ook rechtstreeks op het form werken en dan heb je nog de properties. M'n code voor m'n form:

<UserControl x:Class="Music_Player_v1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="170" d:DesignWidth="590">

<Grid x:Name="LayoutRoot" Background="White">
<Button Content="PLAY" Height="30" HorizontalAlignment="Left" Name="Play" VerticalAlignment="Top" Width="80" Margin="500,90,0,0"></Button>
<Button Content="Toepassen" Height="30" HorizontalAlignment="Left" Name="Toepassen1" VerticalAlignment="Top" Width="80" Margin="500,10,0,0"></Button>
<Button Content="Toepassen" Height="30" HorizontalAlignment="Left" Name="Toepassen2" VerticalAlignment="Top" Width="80" Margin="500,50,0,0"></Button>
<ProgressBar Height="30" HorizontalAlignment="Left" Margin="10,130,0,0" Name="ProgressBar1" VerticalAlignment="Top" Width="570" Maximum="100" Value="0"></ProgressBar>
<ComboBox Height="30" HorizontalAlignment="Left" Margin="10,10,0,0" Name="comboBox1" VerticalAlignment="Top" Width="480">
<ComboBoxItem Name="comboboxitem1" Content="AC-DC" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480" />
<ComboBoxItem Name="comboboxitem2" Content="Aerosmith" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480" />
<ComboBoxItem Name="comboboxitem3" Content="Bullet for my Valentine" MaxHeight="20" MaxWidth="480" MinHeight="20" MinWidth="480" />
<ComboBoxItem Name="comboboxitem4" Content="Iron Maiden" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480" />
<ComboBoxItem Name="comboboxitem5" Content="Jonas Brothers" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480" />
<ComboBoxItem Name="comboboxitem6" Content="Nickelback" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480" />
<ComboBoxItem Name="comboboxitem7" Content="Rammstein" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480" />
<ComboBoxItem Name="comboboxitem8" Content="The opposites" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480" />
</ComboBox>
<ComboBox Height="30" HorizontalAlignment="Left" Name="comboBox2" VerticalAlignment="Top" Width="480" Margin="10,50,0,0">
<ComboBoxItem Name="comboboxitem9" Content="Highway to hell" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480" IsEnabled="True" Visibility="Collapsed" />
<ComboBoxItem Name="comboboxitem10" Content="Back in black" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem11" Content="For those about to rock we salute you" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem12" Content="Flick of the switch" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem13" Content="74 jailbreak" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem14" Content="Fly on the wall" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem15" Content="Who made who" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem16" Content="The razor's edge" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitme17" Content="Ballbreaker" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem18" Content="Stiff upper lip" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem19" Content="Black ice" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem20" Content="Big ones" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480" />
<ComboBoxItem Name="comboboxitem21" Content="Domination" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem22" Content="Fever" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem23" Content="Hand of blood " MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem24" Content="Scream, aim, fire" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem25" Content="Tears don't fall" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem26" Content="The poison" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem27" Content="Iron Maiden" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem28" Content="It's about time" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem29" Content="Lines, vines and trying times" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem30" Content="Jonas Brothers" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem31" Content="A little bit longer" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem32" Content="Curb" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem33" Content="Liebe ist für alle da" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem34" Content="Rosenrot" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
<ComboBoxItem Name="comboboxitem35" Content="(geen album, aparte liedjes)" MaxHeight="20" MaxWidth="500" MinHeight="20" MinWidth="480"/>
</ComboBox>
<ComboBox Height="30" HorizontalAlignment="Left" Margin="10,90,0,0" Name="comboBox3" VerticalAlignment="Top" Width="480" />
</Grid>
</UserControl>

En dan me code om de buttons en comboboxen opdrachten te geven (dit is wel in de VB variant, je kunt dit ook nog doen in C#)

Partial Public Class MainPage
Inherits UserControl

Public Sub New()
InitializeComponent()
End Sub

Private Sub Toepassen1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Toepassen1.Click
If ProgressBar1.Value = 33 Then
MessageBox.Show("Fout, om deze error te voorkomen moet U eerst een album selecteren bij de volgende stap.")
Else
ProgressBar1.Value = 33
(Hier staat de 1 regel code die altijd blokkeert: )If comboBox1.SelectionBoxItem = comboboxitem1 Then

comboboxitem9.Visibility = Windows.Visibility.Visible
End If
End If
End Sub

Private Sub MainPage_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded

End Sub

Private Sub comboboxitem9_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles comboboxitem9.Loaded

End Sub
End Class
 
Ik heb de oplossing op m'n vraag gevonden en omdat er anderen misschien ook met dit probleem zitten zal ik m'n oplossing posten:

Private Sub Toepassen1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Toepassen1.Click
If ProgressBar1.Value = 33 Then
MessageBox.Show("Fout, om deze error te voorkomen moet U eerst een album selecteren bij de volgende stap.")
Else
ProgressBar1.Value = 33
If comboboxitem1.IsSelected Then
comboboxitem9.Visibility = Windows.Visibility.Visible
End If
End If
End Sub
 
nu heb ik opnieuw een probleem met die combobox :s weet er toevallig iemand hoe ik instel dat je pas naar de volgende stap kan als de vorige is aangeduid? Dit is m'n bedoeling: je duid een comboboxitem aan en kan de volgende items zien. Maar duid je geen comboboxitem aan krijg je een error.
 
ik ken niet precies de syntax maarre voeg een ELSE toe en daar een bericht van dat hij eerste eerst moet selectere

Code:
If comboboxitem1.IsSelected Then
comboboxitem9.Visibility = Windows.Visibility.Visible
[B][COLOR="Navy"]ELSE
[BERICHT][/COLOR][/B]
End If
 
Laatst bewerkt:
dat zou misschien wel kunnen lukken maar als ik doe else bij comboboxitem1 en je selecteert comboboxitem2 dan ga je de volgende comboboxitems zien en het bericht bij de else of niet?
 
kheb het juist getest en selecteer je dan comboboxitem2 krijg je error en de bijhorende comboboxitem in combobox2
 
if en else is zeg maar zo

kleur van ballon = blauw

if(ballon == "blauw")
{
ga verder als ballon blauw is
}
else
{
ga verder als ballon niet blauw is
}

dus als ballon bijv. rood is dan kom je in de else.

ik kan het fout hebbe maar ik denk dat deze code
comboboxitem1.IsSelected
aangeeft of er iets geselecteerd is in combobox1 of niet.
daardoor gebruik je de if en else ;)
 
nou wat je zegt kan wel kloppen maar het probleem is dat ik meerdere keren de if statement gebruik
ik doe namelijk:
if comboboxitem1.IsSelected then
en de opdracht
end if
if comboboxitem2.IsSelected then
en de opdracht
end if
(dit doe ik zo 8 keer)
en ik denk niet dat je 8 keer else kunt in vullen of wel soms?
 
de logica is dit

  1. Bij het laden zet je alle boxen disabled of invisible alleen de eerste laat je wel aan
  2. Daarna als je 1e iets geselecteerd hebt dan wordt de 2e enabled of visible
zo hoeft je ook niet meer al die onnodige checks te gaan maken omdat de gebruiker er gwn weg niet op kan klikken
 
we werken beetje doorelkaar heen :P
maar reactie op jouw laatste post.
een if die kan een else hebben
maar een if die kan dan weer een elseif hebben
dat is eigenlijk de else waar ook weer een if inzit.
geneste if statement ;)
 
ik zie nu pas dat je gereageert had :o ik ga het even verder uit proberen en laat nog wel weten of het gelukt is of niet want ja als het niet lukt heb ik nog altijd een probleem.
 
Graag gedaan,
zou je nog de oplossing willen vermelden en bovenaan willen klikken op status opgelost ;)

Byess VRC
 
M'n oplossing:

If comboboxitem1.IsSelected then
(de opdracht)
ElseIf comboboxitem2.IsSelected then
(de opdracht)
(enz...)
(en op het einde)
Else
Messagebox.show("error")
End If

Zo?
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan