Здравствуйте. Я начинающий, но срочно нужно решить такую проблему: Существует 3 комбобокса. 1) № Здания 2) Этаж 3) Комната Нужно чтобы при выборе допустим Здания №1 в комбобоксе1 открывались значения второго комбобокса (допустим 4 этажа, каждый в своем элементе комбобокса2), а когда выбиралось значение в кб2, появлялись доступные значения в кб3. И только после этого можно было бы нажать кнопку "Поиск", которая в зависимости от значений - выводила бы определенную картинку. Ниже привожу наработки MainPage | Код | <UserControl x:Class="SilverlightApplication4.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" xmlns:uriMapper="clr-namespace:System.Windows.Navigation;assembly=System.Windows.Controls.Navigation" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"> <Grid x:Name="LayoutRoot" Style="{StaticResource LayoutRootGridStyle}"> <Image HorizontalAlignment="Stretch" Name="image1" Stretch="Fill" VerticalAlignment="Top" Source="/SilverlightApplication4;component/Images/HneuHeader.png" DataContext="{Binding}" Height="170" /> <navigation:Frame x:Name="ContentFrame" Style="{StaticResource ContentFrameStyle}" Source="/Home" BorderThickness="1" Margin="218,176,12,18"> <navigation:Frame.UriMapper> <uriMapper:UriMapper> <uriMapper:UriMapping Uri="" MappedUri="/Views/Home.xaml" /> <uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Views/{pageName}.xaml" /> </uriMapper:UriMapper> </navigation:Frame.UriMapper> </navigation:Frame> <sdk:TabControl Height="280" HorizontalAlignment="Left" Margin="12,176,0,0" Name="tabControl1" VerticalAlignment="Top" Width="200"> <sdk:TabItem Header="Аудиторії" Name="tabItem1"> <Grid Height="243"> <TextBlock Height="23" HorizontalAlignment="Center" Margin="6,6,85,0" Name="textBlock1" Text="Оберіть корпус" VerticalAlignment="Top" Width="97" /> <ComboBox Height="23" Margin="6,22,6,0" Name="comboBox1" VerticalAlignment="Top" SelectionChanged="comboBox1_SelectionChanged" DataContext="{Binding}" ItemsSource="{Binding}"> <ComboBoxItem Content="Головний корпус" IsSelected="True" Tag="1"/> <ComboBoxItem Content="Лекційний корпус" Tag="2"/> <ComboBoxItem Content="Перший корпус" Tag="3"/> <ComboBoxItem Content="Другий корпус" Tag="4"/> </ComboBox> <TextBlock Height="23" HorizontalAlignment="Left" Margin="6,60,0,0" Name="textBlock2" Text="Оберіть поверх" VerticalAlignment="Top" Width="114" /> <ComboBox Height="23" Margin="6,0,6,144" Name="comboBox2" VerticalAlignment="Bottom" SelectionChanged="comboBox2_SelectionChanged"> <ComboBoxItem Content="Перший поверх" IsSelected="True" /> <ComboBoxItem Content="Другий поверх" /> <ComboBoxItem Content="Третій поверх" /> <ComboBoxItem Content="Четвертий поверх" /> </ComboBox> <Button Content="Знайти" Margin="6,0,6,6" Name="button1" Height="35" VerticalAlignment="Bottom" /> <TextBlock Height="23" HorizontalAlignment="Left" Margin="6,117,0,0" Name="textBlock3" Text="Оберіть аудиторію" VerticalAlignment="Top" Width="114" /> <ComboBox Height="23" Margin="6,0,6,87" Name="comboBox3" VerticalAlignment="Bottom" /> </Grid> </sdk:TabItem> <sdk:TabItem Header="Інше" Name="tabItem2"> <Grid> <ListBox Height="181" HorizontalAlignment="Left" Margin="6,6,0,0" Name="listBox1" VerticalAlignment="Top" Width="176" /> <Button Content="Побачити на мапі" Height="35" HorizontalAlignment="Left" Margin="6,202,0,0" Name="button2" VerticalAlignment="Top" Width="176" /> </Grid> </sdk:TabItem> </sdk:TabControl> <Image Margin="276,114,0,18" Name="image2" Stretch="Fill" Source="/SilverlightApplication4;component/Images/MainMap3.png" HorizontalAlignment="Center" Width="700" /> </Grid> </UserControl>
|
И попытки в C# в этом же проекте | Код | using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Navigation; using System.Windows.Shapes; namespace SilverlightApplication4 { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (Convert.ToString(comboBox1.SelectedItem) == "aaaa") { comboBox2.Items.Insert(0,"знач1" ); comboBox2.Items.Insert(1, "знач2"); comboBox2.Items.Insert(2, "знач3"); } } } }
|
Заранее благодарен Всем, кто сможет или хотя бы попытается оказать помощь. Спасибо!
|