简体   繁体   中英

How to make a property visible to the designer in WPF (vb.net, Visual Studio 2015)

I'm new to WPF and have searched for a solution to the following but the things that I've tried haven't worked.

I am trying to develop a custom user control. The visual interface is a simple listbox.

<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>

The code behind this is going to have a method that will populate the listbox, but to do this it needs a couple of properties to be set. The best time to set these is design time (they are our domain and users OU)

To this end I have this code....

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
.
.
.

I then add this control to my mainscreen (window class)

How do I make the property show up in the list of properties in the designer?

Hoping someone can help.

I have part solved it. Now it shows up but I need to work out how to make it accept a string rather than value.

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

I had done this before following another example I found online, but had not compiled the class before using it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM