Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.27 KB | None | 0 0
  1. <Window x:Class="Html5Mapper.Mapper.MainWindow"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:wpt="http://schemas.xceed.com/wpf/xaml/toolkit"
  5. Title="HTML mapper" Height="300" Width="600" >
  6. <Window.DataContext>
  7. <Binding Path="Main" Source="{StaticResource Locator}"/>
  8. </Window.DataContext>
  9.  
  10. <ListBox Name="lbFiles" ItemsSource="{Binding Filescollection, Mode=OneWay}" Width="240" Height="220">
  11. <ListBox.ItemTemplate>
  12. <DataTemplate>
  13. <Grid Margin="0,2">
  14. <Grid.ColumnDefinitions>
  15. <ColumnDefinition Width="*" />
  16. <ColumnDefinition Width="100" />
  17. </Grid.ColumnDefinitions>
  18. <Image Source="HTML.png" Height="40" Width="32" />
  19. <TextBlock Grid.Column="1" Text="{Binding Name}" />
  20. </Grid>
  21. </DataTemplate>
  22. </ListBox.ItemTemplate>
  23. </ListBox>
  24.  
  25. public ObservableCollection<Files> Filescollection { get; set; }
  26. public MainViewModel()
  27. {
  28. this.Filescollection = new ObservableCollection<Files>();
  29. SelectFilesAction();
  30. }
  31.  
  32. private void SelectFilesAction()
  33. {
  34. this.Filescollection.Add(new Files { Name = "index.html", Path = "C:\Files"});
  35. //lbFiles.ItemsSource = docs;
  36. }
  37.  
  38. public ObservableCollection<Files> Filescollection {get;set;}
  39.  
  40. public MainViewModel()
  41. {
  42. this.Filescollection = new ObservableCollection<Files>();
  43. SelectFilesAction();
  44. }
  45.  
  46. private void SelectFilesAction()
  47. {
  48. Filescollection.Add(new Files { Name = "index.html", Path = "C:\Files"});
  49. }
  50.  
  51. <Window.DataContext>
  52. <Binding Path="Main" Source="{StaticResource Locator}"/>
  53. </Window.DataContext>
  54.  
  55. <Window DataContext="{StaticResource MainViewModel}">
  56.  
  57. <UserControl x:Class="RetailPOS.View.Usercontrols.MainWindow.Products"
  58. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  59. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  60. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  61. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  62. xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
  63. mc:Ignorable="d"
  64. xmlns:ctrl="clr-namespace:RetailPOS.View.Usercontrols.MainWindow"
  65. d:DesignHeight="200" d:DesignWidth="490" **DataContext="{Binding Source={StaticResource Locator}, Path=CategoryVM}"**
  66. xmlns:my="clr-namespace:WpfLab.Controls;assembly=WpfLab.Controls">
  67. <UserControl.Resources>
  68. </UserControl.Resources>
  69. <Grid Width="490" Height="360">
  70. <ListBox Name="LstProduct" ItemsSource="{Binding LstProduct}" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
  71. <ListBox.ItemsPanel>
  72. <ItemsPanelTemplate>
  73. <WrapPanel Orientation="Horizontal" Margin="0" Height="Auto" Width="490" >
  74. </WrapPanel>
  75. </ItemsPanelTemplate>
  76. </ListBox.ItemsPanel>
  77. <ListBox.ItemTemplate>
  78. <DataTemplate>
  79. <Button Margin="1" Content="{Binding Name}" Height="53" Background="{Binding Color}" HorizontalAlignment="Right" Width="79"
  80. Command="{Binding DataContext.ShowProductCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ItemsControl}}}"
  81. CommandParameter="{Binding}">
  82. </Button>
  83. </DataTemplate>
  84. </ListBox.ItemTemplate>
  85. </ListBox>
  86.  
  87. </Grid>
  88. </UserControl>
  89.  
  90. private ObservableCollection<ProductDTO> _lstProduct;
  91. public ObservableCollection<ProductDTO> LstProduct
  92. {
  93. get { return _lstProduct; }
  94. set
  95. {
  96. _lstProduct = value;
  97. RaisePropertyChanged("LstProduct");
  98. }
  99. }
  100.  
  101. /// <summary>
  102. /// Get all Commonly Used Products
  103. /// </summary>
  104. /// <returns>returns list of all Commonly Used products present in database</returns>
  105. private void FillCommonProducts()
  106. {
  107. LstProduct = new ObservableCollection<ProductDTO>(from item in ServiceFactory.ServiceClient.GetCommonProduct()
  108. select item);
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement