예제 #1
0
        private void AddShowPanel(PagedResultDto <ParkDto> result)
        {
            parkDtos = result.Items;

            UserControls.ParkInfo parkInfo;
            var width = (this.ActualWidth - 5 * 80) / 4;

            foreach (var park in parkDtos)
            {
                parkInfo                      = new UserControls.ParkInfo();
                parkInfo.Margin               = new Thickness(80, 100, 0, 0);
                parkInfo.Width                = width; //每行展示4个
                parkInfo.Height               = 250;
                parkInfo.DataContext          = park;
                parkInfo.MouseLeftButtonDown += ParkInfo_MouseLeftButtonDown;
                ShowPanel.Children.Add(parkInfo);
            }
            var parkAdd = new UserControl();

            parkAdd.Width  = width;
            parkAdd.Height = 250;

            parkAdd.Margin               = new Thickness(80, 100, 0, 0);
            parkAdd.Template             = (ControlTemplate)FindResource("AddParkControlTemplate");
            parkAdd.MouseLeftButtonDown += ParkAdd_MouseLeftButtonDown;
            ShowPanel.Children.Add(parkAdd);
        }
예제 #2
0
        private void ParkInfo_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            UserControls.ParkInfo parkInfo = sender as UserControls.ParkInfo;
            var park = parkInfo.DataContext as ParkDto;

            park.IsSelected = true;

            if (_mainWindowViewModel.SelectParkDto != null && _mainWindowViewModel.SelectParkDto != park)
            {
                _mainWindowViewModel.SelectParkDto.IsSelected = false;
            }
            _mainWindowViewModel.SelectParkDto = park;
        }