<Window x:Class="CollectionBinding.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:data="clr-namespace:ClassLibrary;assembly=ClassLibrary"
        xmlns:local="clr-namespace:CollectionBinding"
        Title="MainWindow" Height="523.038" Width="361.701">
    <Window.Resources>
        <ObjectDataProvider IsAsynchronous="True" ObjectType="{x:Type data:StoreDB}" MethodName="GetProducts" x:Key="DataProvider"></ObjectDataProvider>
        <local:PriceConverter x:Key="PriceConverter"></local:PriceConverter>
        <local:ImageConverter x:Key="ImageConverter"></local:ImageConverter>
        <local:PriceToBrushConverter Min="10" Max="100" x:Key="PriceToBrushConverter"></local:PriceToBrushConverter>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <ListBox Margin="3" Grid.Row="0" Name="lstProducts" Height="120" 
                 ScrollViewer.VerticalScrollBarVisibility="Visible" ItemsSource="{Binding Source={StaticResource DataProvider}}" 
                 DisplayMemberPath="ModelName" AlternationCount="3">
            <ListBox.ItemContainerStyle>
                <Style>
                    <Setter Property="ListBoxItem.Background" Value="LightSteelBlue"></Setter>
                    <Setter Property="ListBoxItem.Margin" Value="5"></Setter>
                    <Setter Property="ListBoxItem.Padding" Value="3"></Setter>
                    <Style.Triggers>
                        <Trigger Property="ItemsControl.AlternationIndex" Value="1">
                            <Setter Property="ListBoxItem.Background" Value="LightBlue"></Setter>
                        </Trigger>
                        <Trigger Property="ItemsControl.AlternationIndex" Value="2">
                            <Setter Property="ListBoxItem.Background" Value="Brown"></Setter>
                        </Trigger>
                        <Trigger Property="ListBoxItem.IsSelected" Value="True">
                            <Setter Property="ListBoxItem.Background" Value="DarkRed"></Setter>
                            <Setter Property="ListBoxItem.Foreground" Value="White"></Setter>
                            <Setter Property="ListBoxItem.BorderBrush" Value="Red"></Setter>
                            <Setter Property="ListBoxItem.BorderThickness" Value="2"></Setter>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </ListBox.ItemContainerStyle>
        </ListBox>
        <StackPanel Margin="3" Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
            <Button Margin="3" MinWidth="100" Name="btnGetProducts" Click="btnGetProducts_Click_1">GetProducts</Button>
        </StackPanel>
        <Grid Margin="3" Name="grid" Grid.Row="2" DataContext="{Binding ElementName=lstProducts,Path=SelectedItem}"
              Background="{Binding Path=UnitCost, Converter={StaticResource PriceToBrushConverter}}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <TextBlock Margin="3" Grid.Row="0" Grid.Column="0">CategoryID:</TextBlock>
            <TextBox Name="txtCategoryID" Margin="3" Grid.Row="0" Grid.Column="1" Text="{Binding Path=CategoryID}"></TextBox>

            <TextBlock Margin="3" Grid.Row="1" Grid.Column="0">ModelNumber:</TextBlock>
            <TextBox Name="txtModelNumber" Margin="3" Grid.Row="1" Grid.Column="1" Text="{Binding Path=ModelNumber}"></TextBox>

            <TextBlock Margin="3" Grid.Row="2" Grid.Column="0">ModelName:</TextBlock>
            <TextBox Name="txtModelName" Margin="3" Grid.Row="2" Grid.Column="1" Text="{Binding Path=ModelName}"></TextBox>

            <TextBlock Margin="3" Grid.Row="3" Grid.Column="0">ProductImage:</TextBlock>
            <Border Grid.Row="3" Grid.Column="1" Margin="3" BorderBrush="Black" BorderThickness="1"  Width="100" Height="100" >
                <Image Source="{Binding Path=ProductImage,Converter={StaticResource ImageConverter}}"></Image>

            </Border>
           
            <TextBlock Margin="3" Grid.Row="4" Grid.Column="0">UnitCost:</TextBlock>
            <TextBox Name="txtUnitCost" Margin="3" Grid.Row="4" Grid.Column="1" Text="{Binding Path=UnitCost,Converter={StaticResource PriceConverter}}">
                
            </TextBox>
            
            <TextBox Name="txtDescription" Margin="3" Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2" TextWrapping="Wrap"
                     Text="{Binding Path=Description}" ScrollViewer.VerticalScrollBarVisibility="Visible"></TextBox>
        </Grid>
    </Grid>
</Window>

WPF 列表样式的更多相关文章

  1. WPF - Group分组对ListBox等列表样式的约束

    原文:WPF - Group分组对ListBox等列表样式的约束 在做WPF主题支持时,出现一个分组引起的莫名错误,可是折腾了我一番.在没有使用样式时,列表分组很正常,使用了别人写的ListBox列表 ...

  2. CSS3初学篇章_5(背景样式/列表样式/过渡动画)

    背景样式 1.背景颜色语法:background-color : transparent | color body { background-color:#CCCCCC;} 2.渐变色彩语法:back ...

  3. 求助 WPF ListViewItem样式问题

    求助 WPF ListViewItem样式问题 .NET 开发 > Windows Presentation Foundation Вопрос 0 Нужно войти <Style ...

  4. SharePoint 2010 修改默认列表样式

    SharePoint 2010  修改默认列表样式 :可以通过修改 下面两个全局配置进行修改.(未完..更新中...)  C:\Program Files\Common Files\Microsoft ...

  5. 实现Word的列表样式

    1.创建列表,但是不要求在文档视图中显示的层级列表 1)首先是要先把层级建立好,然后选中要编号文字.开始->段落->多级列表,选择一个列表样式,会默认所有的编号文字都是一级: 2)选择&q ...

  6. css中的列表样式

    在网页设计中,我们经常将某些具有相似功能的标签放在同一组中,这时我们经常会用到列表标签(无序列表ul,有序列表ol),在列表标签中对列表样式的设计可以使我们的页面得到一定程度的美化. 在css中对列表 ...

  7. WPF GroupBox 样式分享

    原文:WPF GroupBox 样式分享 默认样式 GroupBox 样式分享" title="WPF GroupBox 样式分享"> 添加样式后 GroupBox ...

  8. WPF DataGrid 样式设置

    隔行换色,鼠标单击,悬浮样式都有,其具体效果如图 1 所示. 图 1 WPF DataGrid 样式设置效果图 其中: 界面设计代码下所示 ? + 查看代码 1 2 3 4 5 6 7 8 9 10 ...

  9. WPF 列表开启虚拟化的方式

    正确开启虚拟化的方式 列表如ListBox,ListView,TreeView,GridView等,开启虚拟化 ScrollViewer设置CanContentScroll=True 直接在模板中,设 ...

随机推荐

  1. pycharm的集成vim

    pycharm的集成vim 1. 基本使用 激活码 BIG3CLIK6F-eyJsaWNlbnNlSWQiOiJCSUczQ0xJSzZGIiwibGljZW5zZWVOYW1lIjoibGFuIHl ...

  2. ios app初始化和数据迁移的设计思路

    整体思路 一般app启动之后,都有一个初始化的过程. 此外兴许app升级,还须要考虑数据迁移.所以初始化和数据迁移的框架.在初期的版本号就要考虑好 总结一下我们的app採取的方案: 1.在持久化的文件 ...

  3. PatentTips - Hardware virtualization such as separation kernel hypervisors

    BACKGROUND 1. Field Innovations herein pertain to computer virtualization, computer security and/or ...

  4. Angular.js回想+学习笔记(1)【ng-app和ng-model】

    Angular.js中index.html简单结构: <!doctype html> <html ng-app> <head> <script src=&qu ...

  5. MFC获取各个窗体(体)之间的指针(对象)

    MFC在非常多的对话框操作中,我们常常要用到在一个对话框中调用还有一个对话框的函数或变量.能够用例如以下方法来解决.    HWND hWnd=::FindWindow(NULL,_T("S ...

  6. CSS知识总结之浏览器

    web页面浏览器渲染过程 1.解析html文件,并构建DOM树: 在DOM树中,每一个html标签都有一个对应的节点,并且每一个文本也有一个对应 的节点(js的textNode),DOM树的根节点就是 ...

  7. JSP 九大内置对象(转)

    九大对象: 内置对象(又叫隐含对象,有9个内置对象):不需要预先声明就可以在脚本代码和表达式中随意使用 out: javax.servlet.jsp.JspWriter类型,代表输出流的对象.作用域为 ...

  8. BZOJ 3932 - 主席树

    传送门 题目分析 在只打会主席树模板的情况下做了这道题,也算是深有体会. 首先任务可以差分:一个任务是(s, e, p), 则在s处+1, 在e+1处-1,符合前缀.但是我们要查询指定时间的前k任务之 ...

  9. Java访问修饰符(转)

    类.方法.成员变量和局部变量的可用修饰符 修饰符 类 成员方法 构造方法 成员变量 局部变量 abstract(抽象的) √ √ - - - static (静态的) - √ - √ - public ...

  10. Crystal Report - 水晶报表导出文件的格式设置

    水晶报表中自带的导出和打印功能用起来确实很方便,只不过有时候需要导出的文件并不需要那么多种类型,在网上找到一些朋友的代码总结了一下,可以通过代码实现自定义导出文件类型 首先需要定义一个枚举: publ ...