Skip to content

Instantly share code, notes, and snippets.

@akirti
Last active August 29, 2015 14:15
Show Gist options
  • Save akirti/cf0682f78d697c6ef02c to your computer and use it in GitHub Desktop.
Save akirti/cf0682f78d697c6ef02c to your computer and use it in GitHub Desktop.
<telerik:RadSplitContainer
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
x:Class="ClientUI.Module.Section.SectionHeader.View.SectionHeadTools"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400"
Orientation="Vertical"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
telerik:ProportionalStackPanel.RelativeSize="0,20"
Margin="0" Padding="0">
<telerik:RadPaneGroup
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" Margin="0" Padding="0">
<telerik:RadPane IsPinned="True"
CanUserClose="False"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" Margin="0" Padding="0"
PaneHeaderVisibility="Collapsed">
<telerik:RadWrapPanel Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<!-- Groups Combo Box Start-->
<StackPanel>
<StackPanel Margin="5,0">
<TextBlock Text="Choose Group :"/>
</StackPanel>
<telerik:RadComboBox HorizontalAlignment="Left"
VerticalAlignment="Top"
Width="250"
Margin="5"
ItemsSource="{Binding ItemGroupsSource, Mode=TwoWay}"
SelectedItem="{Binding SelectedGroup, Mode=TwoWay}"
DisplayMemberPath="Name"/>
</StackPanel>
<!-- Groups Combo Box End-->
<!-- Itemmaster Combo Box Start-->
<StackPanel>
<StackPanel Margin="5,0">
<TextBlock Text="Choose Items :"/>
</StackPanel>
<telerik:RadComboBox HorizontalAlignment="Left" VerticalAlignment="Top"
Width="250" Margin="5"
ItemsSource="{Binding ItemmasterSource, Mode=TwoWay}"
SelectedItem="{Binding SelectedItemmaster, Mode=TwoWay}"
DisplayMemberPath="Itemname">
</telerik:RadComboBox>
</StackPanel>
<!-- Itemmaster Combo Box End-->
<!-- Action Combo Box Start-->
<StackPanel>
<StackPanel Margin="5,0">
<TextBlock Text="Choose Actions :"/>
</StackPanel>
<telerik:RadComboBox HorizontalAlignment="Left" VerticalAlignment="Top"
Width="250" Margin="5">
<telerik:RadComboBoxItem Content="Item 1"/>
<telerik:RadComboBoxItem Content="Item 2"/>
<telerik:RadComboBoxItem Content="Item 3"/>
</telerik:RadComboBox>
</StackPanel>
<!-- Action Combo Box End-->
</telerik:RadWrapPanel>
</telerik:RadPane>
</telerik:RadPaneGroup>
</telerik:RadSplitContainer>
using ClientUI.Infrastructure.ViewModel;
using ClientUI.Module.Section.SectionHeader.ViewModel;
using Microsoft.Practices.ServiceLocation;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Telerik.Windows.Controls;
namespace ClientUI.Module.Section.SectionHeader.View
{
public partial class SectionHeadTools : RadSplitContainer, ISectionHeadToolsView
{
public SectionHeadTools()
{
InitializeComponent();
if (DesignerProperties.IsInDesignTool == false)
{
DataContext = ServiceLocator.Current.GetInstance<ISectionHeadToolsViewModel>();
}
}
public IViewFirstModel ViewFirstModel
{
get
{
return (ISectionHeadToolsViewModel)DataContext;
}
set
{
DataContext=value;
}
}
}
}
using ClientUI.Web.RiaDomainServices;
using HpmModel;
using OpenRiaServices.DomainServices.Client;
using System;
using System.Collections.ObjectModel;
using System.Net;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Linq;
using Telerik.Windows.Controls;
namespace ClientUI.Module.Section.Services
{
public class ItemHeadDaoService : ViewModelBase
{
private HpmsDomainsRiaDomainContext context;
public ItemHeadDaoService()
{
context = new HpmsDomainsRiaDomainContext();
}
public void LoadGroups(ObservableCollection<Group> ItemsGroupSource, User user, bool isBusy)
{
isBusy = true;
ObservableCollection<Group> Items=null;
EntityQuery<Group> query = null;
EntityQuery<Usergroup> userGroupQuery = null;
query = this.context.GetGroupsQuery().Where(x => x.Status == "A");
if (user != null)
{
if (user.Role == "A")
{
userGroupQuery = this.context.GetUsergroupsQuery();
}
else
{
userGroupQuery = this.context.GetUsergroupsQuery().Where(x => x.Userid == user.Userid);
}
}
this.context.Load<Group>(
query,
LoadBehavior.MergeIntoCurrent,
(lo) => {
if (lo.Entities != null)
{
this.context.Load<Usergroup>(
userGroupQuery,
LoadBehavior.MergeIntoCurrent,
(lp) =>
{
if (lp.Entities != null)
{
Items = new ObservableCollection<Group>(lo.Entities);
ItemsGroupSource = Items;
OnPropertyChanged("ItemGroupsSource");
isBusy = false;
}
},
null
);
}
}, null);
}
public void LoadDefaultItemmaster(ObservableCollection<Itemmaster> ItemmasterSource, bool isBusy)
{
isBusy = true;
this.context.Load<Itemmaster>(
this.context.GetItemmastersQuery().Where(x => x.Status == "A"),
LoadBehavior.MergeIntoCurrent,
(lo) => {
if (lo.Entities != null)
{
ItemmasterSource = new ObservableCollection<Itemmaster>(lo.Entities);
isBusy = false;
OnPropertyChanged("ItemmasterSource");
}
}, null);
}
public void LoadGroupSelectionChange(Group selectedGroup, ObservableCollection<Itemmaster> ItemmasterSource, bool isBusy)
{
isBusy = true;
if (selectedGroup != null)
{
EntityQuery<Itemmaster> query=this.context.GetItemmastersQuery().Where(x => x.Status == "A" && x.Groupid== selectedGroup.Id);
this.context.Load<Itemmaster>(
query,
LoadBehavior.MergeIntoCurrent,
(lo) =>
{
if (lo.Entities != null)
{
ItemmasterSource = new ObservableCollection<Itemmaster>(lo.Entities);
isBusy = false;
OnPropertyChanged("ItemmasterSource");
}
}, null);
}
else
{
isBusy = false;
}
}
}
}
using ClientUI.Module.Section.Services;
using ClientUI.Web.RiaDomainServices;
using HpmModel;
using Microsoft.Practices.Prism.Events;
using System;
using System.Collections.ObjectModel;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
namespace ClientUI.Module.Section.SectionHeader.ViewModel
{
public class SectionHeadToolsViewModel : ViewModelBase, ISectionHeadToolsViewModel
{
readonly IEventAggregator aggregator;
private HpmsDomainsRiaDomainContext context;
private ItemHeadDaoService service;
public SectionHeadToolsViewModel(IEventAggregator _aggregator, ItemHeadDaoService _service)
{
aggregator = _aggregator;
service = _service;
HeadDaoService = new ItemHeadDaoService();
context = new HpmsDomainsRiaDomainContext();
IsBusy = false;
//Deployment.Current.Dispatcher.BeginInvoke(() =>
//{
// service.LoadGroups(ItemGroupsSource, new User() { Userid = "hpmsadmin" }, IsBusy);
// service.LoadDefaultItemmaster(ItemmasterSource, IsBusy);
//});
HeadDaoService = new ItemHeadDaoService();
HeadDaoService.LoadGroups(ItemGroupsSource, new User() { Userid = "hpmsadmin" }, IsBusy);
HeadDaoService.LoadDefaultItemmaster(ItemmasterSource, IsBusy);
}
#region Head Properties
private bool _isBusy;
public bool IsBusy
{
get
{
return _isBusy;
}
set
{
_isBusy = value;
this.OnPropertyChanged(() => IsBusy);
}
}
/// <summary>
/// Holder for Group Combo Box
/// </summary>
private ObservableCollection<Group> _itemGroupsSource;
public ObservableCollection<Group> ItemGroupsSource
{
get
{
return _itemGroupsSource;
}
set
{
_itemGroupsSource = value;
OnPropertyChanged(()=>ItemGroupsSource);
}
}
/// <summary>
/// Holder for Group Combo Box Selected Item
/// </summary>
//SelectedGroup
private Group _SelectedGroup;
public Group SelectedGroup
{
get
{
return _SelectedGroup;
}
set
{
if (_SelectedGroup != value)
{
_SelectedGroup = value;
service.LoadGroupSelectionChange(_SelectedGroup, ItemmasterSource, IsBusy);
}
this.OnPropertyChanged(() => SelectedGroup);
}
}
/// <summary>
/// Holder for Item master Combo Box
/// </summary>
private ObservableCollection<Itemmaster> _ItemmasterSource;
public ObservableCollection<Itemmaster> ItemmasterSource
{
get
{
return _ItemmasterSource;
}
set
{
_ItemmasterSource = value;
OnPropertyChanged(() => ItemmasterSource);
}
}
/// <summary>
/// Holder for Itemmaster Combo Box Selected Item
/// </summary>
//SelectedItemmaster
private Itemmaster _SelectedItemmaster;
public Itemmaster SelectedItemmaster
{
get
{
return _SelectedItemmaster;
}
set
{
_SelectedItemmaster = value;
this.OnPropertyChanged(() => SelectedItemmaster);
}
}
private ItemHeadDaoService _HeadDaoService;
public ItemHeadDaoService HeadDaoService
{
get
{
return _HeadDaoService;
}
set
{
_HeadDaoService = value;
this.OnPropertyChanged(() => HeadDaoService);
}
}
#endregion
}
}
@akirti
Copy link
Author

akirti commented Feb 17, 2015

Why ItemHeadDaoService is not able to change the property of SectionHeadToolsViewModel .

@akirti
Copy link
Author

akirti commented Feb 17, 2015

My RadComboBoxes are not loading by this code.

@michaellperry
Copy link

There's a lot to go through here. Let me have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment