C# 更新 Uri 字符串
当选择列表项时,我得到了此代码,“teamsite”字符串发生变化。 但是我如何才能将 Uri 添加到 teamsite 字符串,我希望 new Uri(teamsite)
获得与当我从列表中选择一个项目时的 teamsite 字符串相同的值 因此,当我选择 Elite Junioren
项目时,new Uri(teamsite)
等于 "http://www.test2.com"
而不是"http://www.test.com"
string teamsite = "http://www.test.com";
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
new Uri(teamsite),
}
private void List_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
string teamsitecheck = (string)List.SelectedItem;
if (teamsitecheck == "Elite Junioren")
{
teamsite = "http://www.test2.com";
}
else if (teamsitecheck == "Elite Aspiranten")
{
teamsite = "http://www.test3.com";
}
}
我希望我已经解释得足够好,如果需要的话请向我询问更多解释!
(抱歉我的语法不好)
I got this code when a list item is selected the "teamsite" string changes.
but how can i get the Uri addept to the teamsite string, i want new Uri(teamsite)
to get the same value as the teamsite string is when i have chosen a item from the list
so when i chose the Elite Junioren
item, the new Uri(teamsite)
equals "http://www.test2.com"
instead of "http://www.test.com"
string teamsite = "http://www.test.com";
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
new Uri(teamsite),
}
private void List_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
string teamsitecheck = (string)List.SelectedItem;
if (teamsitecheck == "Elite Junioren")
{
teamsite = "http://www.test2.com";
}
else if (teamsitecheck == "Elite Aspiranten")
{
teamsite = "http://www.test3.com";
}
}
i hope i have explained it well enough, ask me for more explenation if it is needed!
(sorry for my bad grammer)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定你在问什么(我什至不知道这是Silverlight、WPF、WinForm等)。
但是,不要在代码中显式映射,而是将 ListItem 的值(值与 Text 不同,但如果未指定则默认为它)设置为适当的团队站点名称,以便在代码中您可以执行以下操作:
I'm not sure what you are asking (I don't even know if this is Silverlight, WPF, WinForm, etc.).
However, instead of explicitly mapping in your code, how about setting the value of the ListItem (value is different from Text, but defaults to it if not specified) to the appropriate teamsite name, so that in your code you can do: