小编Lov*_*ypt的帖子

创建后面的datatemplate代码

我正在尝试为show数据创建一个ListBox视图,我希望它包含一个ListBox,其中包含2列"产品ID和产品条形码"的datatemplate

我想用纯C#代码创建它,或者如果可能的话通过xaml加载它?如果我可以创建一个模板,我可以将c#作为各种资源.

到目前为止我所做的是:在XAML中:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="37*" />
        <RowDefinition Height="88*" />
    </Grid.RowDefinitions>
    <TextBlock Text="Type Your Search :" HorizontalAlignment="Left"  VerticalAlignment="Bottom" Width="112" Height="15.96" Margin="20,0,0,4" />

    <TextBox HorizontalAlignment="Right" VerticalAlignment="Bottom" Height="25" Width="300" Margin="0,0,44,0" x:Name="txtCAuto" TextWrapping="NoWrap" HorizontalContentAlignment="Right" />

    <ListBox x:Name="lbSuggestion" SelectionChanged="lbSuggestion_SelectionChanged" Foreground="Black" Width="300" Margin="0,0,44,0"  FlowDirection="RightToLeft" Background="LightYellow" Grid.Row="1" Visibility="Collapsed"  ScrollViewer.HorizontalScrollBarVisibility="Auto" ItemsSource="{Binding}"  HorizontalAlignment="Right" VerticalAlignment="Top" HorizontalContentAlignment="Right" BorderBrush="Transparent"  Grid.IsSharedSizeScope="True">
    </ListBox>
</Grid>
Run Code Online (Sandbox Code Playgroud)

在代码背后:

string typedString = txtCAuto.Text.ToUpper();
        List<string> autoList = new List<string>();
        autoList.Clear();

         prodDetails ps = SelProd4Sale();

        foreach (string item in ps.ProdBrcdList)
        {
            if (!string.IsNullOrEmpty(txtCAuto.Text))
            {
                if (item.StartsWith(typedString))
                {
                    //autoList.Add(item); …
Run Code Online (Sandbox Code Playgroud)

c# wpf c#-4.0

3
推荐指数
1
解决办法
1万
查看次数

如何限制Windows应用程序只使用c#安装一台计算机?

我即将设置我的第一个Windows应用程序,它是用C#Visual studio 2010构建给我的客户的.我想限制每次安装只使用一台计算机,但我不知道该怎么做.

任何人都可以指导我如何实现这一目标吗?

.net c# licensing activation visual-studio-2010

2
推荐指数
1
解决办法
3567
查看次数

标签 统计

c# ×2

.net ×1

activation ×1

c#-4.0 ×1

licensing ×1

visual-studio-2010 ×1

wpf ×1