VB.net WPF Combox 下拉列表 树形显示

前台UI页

<ComboBox HorizontalAlignment="Left" Margin="124,81,0,0" VerticalAlignment="Top" Width="300" Height="28" Name="treeUserOrgList" MaxDropDownHeight="1200" IsEditable="True" Cursor="Hand" >
<ComboBoxItem Height="0"></ComboBoxItem>
<ComboBoxItem >
<ComboBoxItem.Template>
<ControlTemplate>
<TreeView Name="lftTree" Margin="0" ItemsSource="{Binding}" SelectedItemChanged="lftTree_SelectedItemChanged" 
DisplayMemberPath="{Binding text}" SelectedValuePath="{Binding id}" Height="200">
<TreeView.ItemContainerStyle>
<Style TargetType="TreeViewItem">
<Setter Property="IsExpanded" Value="{Binding checked}"></Setter>
</Style>
</TreeView.ItemContainerStyle>
<TreeView.ItemTemplate>
<HierarchicalDataTemplate 
ItemsSource="{Binding children}">
<TextBlock Text="{Binding text}"></TextBlock>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
</ControlTemplate>
</ComboBoxItem.Template>
</ComboBoxItem>
</ComboBox>

后台逻辑代码

treeUserOrgList.DataContext =getUserOrgList()

 

''' <summary>
''' 获取所属组织
''' </summary>
''' <returns></returns>
Public Shared Function getUserOrgList() As List(Of UserOrgList)
Try
Dim userinfo As UserInfo = Application.Current.Properties("userinfo")
Dim userGuid As Guid = userinfo.UserGuid
Dim UrlAddress As String = ConfigurationManager.AppSettings("UserOrgComboxList").ToString()
Dim strBuild As New StringBuilder
strBuild.Clear()
strBuild.Append(UrlAddress)
strBuild.Append(userGuid)
Dim URL As String = strBuild.ToString()
Dim jsonresult As String = PostWebApi.GetData(URL)
Dim result = JsonConvert.DeserializeObject(Of List(Of UserOrgList))(jsonresult)
Return result
Catch ex As Exception
Throw ex
End Try
End Function

转载于:https://www.cnblogs.com/101Love/p/10510134.html

表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
相关推荐
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页