2017-06-23 37 views
0

我是WPF的新手,已經搜索了以下解決方案,但是我嘗試過的方法沒有奏效。如何使WPF中的設計器可見的屬性(vb.net,Visual Studio 2015)

我想開發一個自定義用戶控件。可視化界面是一個簡單的列表框。

<UserControl x:Class="UserList" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     xmlns:local="clr-namespace:ASManager2017" 
     mc:Ignorable="d" 
     d:DesignHeight="300" d:DesignWidth="300"> 
    <Grid> 
    <ListView x:Name="listView" HorizontalAlignment="Stretch" Height="auto" Margin="5,5,5,5" VerticalAlignment="Stretch" Width="auto"> 
     <ListView.View> 
      <GridView> 
       <GridViewColumn/> 
      </GridView> 
     </ListView.View> 
    </ListView> 
    </Grid> 
</UserControl> 

這背後的代碼將不得不將填充列表框,但要做到這一點,它需要一些屬性進行設置的方法。設置這些的最佳時間是設計時(他們是我們的域和用戶OU)

爲此我有這樣的代碼....

Imports System.DirectoryServices.AccountManagement 
Imports System.ComponentModel 

Public Class UserList 
    Dim Lusers as list(Of UserPrincipalEx) 
    Dim _DomainString as String 
    Dim _OuString as String 

    Public Property OuString 
     Get 
      Return _OuString 
     End Get 
     Set(value) 
      _OuString = value 
     End Set 
    End Property 
. 
. 
. 

然後我將該控件添加到我的mainscreen(窗口類)

如何使設計中的屬性列表中顯示屬性?

希望有人能幫忙。

回答

0

我有部分解決了它。現在顯示出來了,但我需要弄清楚如何讓它接受一個字符串而不是價值。

<Description("ouString"), DisplayName("OU String"), Category("Data")> 
Public Property ouString 
    Get 
     Return _ouString 
    End Get 
    Set(value) 
     _ouString = value 
    End Set 
End Property 

我下面的另一個例子我在網上找到這樣做過,但在使用前沒有編譯的類。

+1

公共屬性ouString As String – soohoonigan

+0

這就解決了它。謝謝。 – Peterp

相關問題