/> C# private void UserControl_Loaded(object sender,RoutedEventArgs e ) { this.DataContext = vm; } 网络服务 amespace StreetLookup.Web { 使用System.Collections.Generic; 使用System.ServiceModel.DomainServices.Hosting; 使用System.ServiceModel.DomainServices.Server; // TODO:创建包含应用程序逻辑的方法。 [EnableClientAccess()] 公共类AddressBookService:DomainService { [Invoke] public IEnumerable< string> GetStreetNames(int StreetNumber) { List< string> names = new List< string>(); if(StreetNumber == 1) { names.Add(Parker St); names.Add(Zachary St); } if(StreetNumber == 2) { 名字.Add(Market St); names.Add(Ocean Ave); } 返回姓名; } } } 问候, Praveen Nelge /*Binding the ViewModel to the XAML*/<usercontrol x:class="StreetLookup.MainPage" xmlns:x="#unknown"> 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="300" d:DesignWidth="400" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" Loaded="UserControl_Loaded" > <grid x:name="LayoutRoot" background="White"> <sdk:label height="27" horizontalalignment="Left" margin="23,34,0,0" name="label1" verticalalignment="Top" width="76" content="Number" xmlns:sdk="#unknown"> <sdk:label height="28" horizontalalignment="Left" margin="178,34,0,0" name="label2" verticalalignment="Top" width="120" content="Street" xmlns:sdk="#unknown"> <textbox height="23" horizontalalignment="Left" margin="23,67,0,0" name="textBox1" verticalalignment="Top" width="120" text="{Binding StreetNumber,Mode=TwoWay}"> <combobox height="23"> SelectedValue="{Binding StreetName, Mode=TwoWay}" ItemsSource="{Binding StreetNames,Mode=OneWay}" HorizontalAlignment="Left" Margin="179,66,0,0" Name="comboBox1" VerticalAlignment="Top" Width="162" /> C# private void UserControl_Loaded(object sender, RoutedEventArgs e) { this.DataContext = vm; }Web Serviceamespace StreetLookup.Web { using System.Collections.Generic; using System.ServiceModel.DomainServices.Hosting; using System.ServiceModel.DomainServices.Server; // TODO: Create methods containing your application logic. [EnableClientAccess()] public class AddressBookService : DomainService { [Invoke] public IEnumerable<string> GetStreetNames(int StreetNumber) { List<string> names = new List<string>(); if (StreetNumber == 1) { names.Add("Parker St"); names.Add("Zachary St"); } if (StreetNumber == 2) { names.Add("Market St"); names.Add("Ocean Ave"); } return names; } } } Regards,Praveen Nelge 这篇关于当另一个组合框选择发生更改时,如何使用触发器执行Combobox选择chage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-19 23:45