Skip to content

Commit 1cf200d

Browse files
author
prabakaran.sangameswaran
committed
Sample review changed committed
1 parent dd88696 commit 1cf200d

36 files changed

+387
-446
lines changed

Samples/ArranageTabs/MainWindow.xaml

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,39 @@
77
xmlns:local="clr-namespace:ArranageTabs"
88
mc:Ignorable="d" WindowStartupLocation="CenterScreen"
99
Title="TabControl - Tab switching" Height="450" Width="800">
10-
<Window.DataContext>
11-
<local:ViewModel/>
12-
</Window.DataContext>
10+
11+
<Window.Resources>
12+
<local:ViewModel x:Key="viewModel">
13+
<local:ViewModel.TabItems>
14+
<syncfusion:TabItemExt Header="tabItem1" Content="This is the first tab item content"/>
15+
<syncfusion:TabItemExt Header="tabItem2" Content="This is the second tab item content"/>
16+
<syncfusion:TabItemExt Header="tabItem3" Content="This is the third tab item content"/>
17+
<syncfusion:TabItemExt Header="tabItem4" Content="This is the fourth tab item content"/>
18+
<syncfusion:TabItemExt Header="tabItem5" Content="This is the fifth tab item content"/>
19+
<syncfusion:TabItemExt Header="tabItem6" Content="This is the sixth tab item content"/>
20+
<syncfusion:TabItemExt Header="tabItem7" Content="This is the seventh tab item content"/>
21+
<syncfusion:TabItemExt Header="tabItem8" Content="This is the eighth tab item content"/>
22+
<syncfusion:TabItemExt Header="tabItem9" Content="This is the ninth tab item content" />
23+
<syncfusion:TabItemExt Header="tabItem10" Content="This is the tenth tab item content" />
24+
</local:ViewModel.TabItems>
25+
</local:ViewModel>
26+
</Window.Resources>
1327

14-
<Grid>
28+
<!--Setting ViewModel as DataContext for the Grid-->
29+
<Grid DataContext="{StaticResource viewModel}">
1530
<Grid.ColumnDefinitions>
1631
<ColumnDefinition Width="*"/>
1732
<ColumnDefinition Width="0.75*"/>
1833
</Grid.ColumnDefinitions>
1934

2035
<Border Grid.Column="0">
2136
<Grid>
22-
<syncfusion:TabControlExt TabItemLayout="{Binding TabItemLayout}"
37+
<syncfusion:TabControlExt ItemsSource="{Binding TabItems}"
38+
TabItemLayout="{Binding TabItemLayout}"
2339
AllowDragDrop="{Binding AllowDragDrop}"
2440
DragMarkerColor="{Binding DragMarkerColor}"
2541
Name="tabControlExt"
2642
Margin="20">
27-
<syncfusion:TabItemExt Header="tabItem1" Content="This is the first tab item content"/>
28-
<syncfusion:TabItemExt Header="tabItem2" Content="This is the second tab item content"/>
29-
<syncfusion:TabItemExt Header="tabItem3" Content="This is the third tab item content"/>
30-
<syncfusion:TabItemExt Header="tabItem4" Content="This is the fourth tab item content"/>
31-
<syncfusion:TabItemExt Header="tabItem5" Content="This is the fifth tab item content"/>
32-
<syncfusion:TabItemExt Header="tabItem6" Content="This is the sixth tab item content"/>
33-
<syncfusion:TabItemExt Header="tabItem7" Content="This is the seventh tab item content"/>
34-
<syncfusion:TabItemExt Header="tabItem8" Content="This is the eighth tab item content"/>
35-
<syncfusion:TabItemExt Header="tabItem9" Content="This is the ninth tab item content" />
36-
<syncfusion:TabItemExt Header="tabItem10" Content="This is the tenth tab item content" />
3743
</syncfusion:TabControlExt>
3844
</Grid>
3945
</Border>

Samples/ArranageTabs/ViewModel/ViewModel.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Syncfusion.Windows.Shared;
22
using Syncfusion.Windows.Tools.Controls;
3+
using System.Collections.ObjectModel;
34
using System.Windows.Media;
45

56
namespace ArranageTabs
@@ -9,14 +10,28 @@ class ViewModel : NotificationObject
910
private bool allowDragDrop = true;
1011
private Brush dragMarkerColor= Brushes.Red;
1112
private TabItemLayoutType tabItemLayout= TabItemLayoutType.MultiLine;
13+
private ObservableCollection<object> tabItems;
14+
15+
public ObservableCollection<object> TabItems
16+
{
17+
get
18+
{
19+
return tabItems;
20+
}
21+
set
22+
{
23+
tabItems = value;
24+
this.RaisePropertyChanged(nameof(TabItems));
25+
}
26+
}
1227

1328
public bool AllowDragDrop
1429
{
1530
get { return allowDragDrop; }
1631
set
1732
{
1833
allowDragDrop = value;
19-
this.RaisePropertyChanged("AllowDragDrop");
34+
this.RaisePropertyChanged(nameof(AllowDragDrop));
2035
}
2136
}
2237
public TabItemLayoutType TabItemLayout
@@ -25,7 +40,7 @@ public TabItemLayoutType TabItemLayout
2540
set
2641
{
2742
tabItemLayout = value;
28-
this.RaisePropertyChanged("TabItemLayout");
43+
this.RaisePropertyChanged(nameof(TabItemLayout));
2944
}
3045
}
3146

@@ -35,8 +50,13 @@ public Brush DragMarkerColor
3550
set
3651
{
3752
dragMarkerColor = value;
38-
this.RaisePropertyChanged("DragMarkerColor");
53+
this.RaisePropertyChanged(nameof(DragMarkerColor));
3954
}
40-
}
55+
}
56+
57+
public ViewModel()
58+
{
59+
TabItems = new ObservableCollection<object>();
60+
}
4161
}
4262
}

Samples/ContextMenu/ViewModel/ViewModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public Visibility DefaultContextMenuItemVisibility
1616
set
1717
{
1818
defaultContextMenuItemVisibility = value;
19-
this.RaisePropertyChanged("DefaultContextMenuItemVisibility");
19+
this.RaisePropertyChanged(nameof(DefaultContextMenuItemVisibility));
2020
}
2121
}
2222

@@ -26,7 +26,7 @@ public bool ShowTabItemContextMenu
2626
set
2727
{
2828
showTabItemContextMenu = value;
29-
this.RaisePropertyChanged("ShowTabItemContextMenu");
29+
this.RaisePropertyChanged(nameof(ShowTabItemContextMenu));
3030
}
3131
}
3232

@@ -36,7 +36,7 @@ public bool ShowTabListContextMenu
3636
set
3737
{
3838
showTabListContextMenu = value;
39-
this.RaisePropertyChanged("ShowTabListContextMenu");
39+
this.RaisePropertyChanged(nameof(ShowTabListContextMenu));
4040
}
4141
}
4242

@@ -46,7 +46,7 @@ public bool IsCustomTabItemContextMenuEnabled
4646
set
4747
{
4848
isCustomTabItemContextMenuEnabled = value;
49-
this.RaisePropertyChanged("IsCustomTabItemContextMenuEnabled");
49+
this.RaisePropertyChanged(nameof(IsCustomTabItemContextMenuEnabled));
5050
}
5151
}
5252

Samples/Databinding/MainWindow.xaml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,39 @@
1616
<syncfusion:TabControlExt ItemsSource="{Binding Path=TabItems}"
1717
EnableLabelEdit="True"
1818
Name="tabControlExt"
19-
Height="200"
20-
Width="380">
19+
Margin="40">
2120

2221
<!--Binding the header text and images for the Tab item-->
2322
<syncfusion:TabControlExt.ItemContainerStyle>
24-
<Style TargetType="syncfusion:TabItemExt">
23+
<Style TargetType="syncfusion:TabItemExt">
2524
<Setter Property="HeaderTemplate">
2625
<Setter.Value>
2726
<DataTemplate>
2827
<TextBlock Text="{Binding Header}" />
2928
</DataTemplate>
3029
</Setter.Value>
3130
</Setter>
32-
<Setter Property="Content" Value="{Binding Content}" />
31+
<Setter Property="ContentTemplate">
32+
<Setter.Value>
33+
<DataTemplate>
34+
<TextBlock Text="{Binding Content}"
35+
VerticalAlignment="Center"
36+
HorizontalAlignment="Center" />
37+
</DataTemplate>
38+
</Setter.Value>
39+
</Setter>
3340
<Setter Property="Image" Value="{Binding Image}" />
3441
<Setter Property="ImageHeight" Value="21" />
3542
<Setter Property="ImageWidth" Value="21" />
3643
<Setter Property="ImageAlignment" Value="{Binding ImageAlignment}" />
3744
</Style>
3845
</syncfusion:TabControlExt.ItemContainerStyle>
39-
40-
<syncfusion:TabControlExt.ItemTemplate>
41-
<DataTemplate>
42-
<TextBlock Text="{Binding Header}"/>
43-
</DataTemplate>
44-
</syncfusion:TabControlExt.ItemTemplate>
46+
4547
<!--Custom UI for edit header template-->
4648
<syncfusion:TabControlExt.EditHeaderTemplate>
4749
<DataTemplate>
4850
<TextBox Text="{Binding Header, Mode=TwoWay}"
49-
Background="Red"
50-
Foreground="White" />
51+
Foreground="Red" />
5152
</DataTemplate>
5253
</syncfusion:TabControlExt.EditHeaderTemplate>
5354
</syncfusion:TabControlExt>

Samples/Databinding/Tabcontrol-binding.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
<Generator>MSBuild:Compile</Generator>
6565
<SubType>Designer</SubType>
6666
</ApplicationDefinition>
67+
<Compile Include="ViewModel\TabItem_ViewModel.cs" />
6768
<Compile Include="ViewModel\ViewModel.cs" />
6869
<Page Include="MainWindow.xaml">
6970
<Generator>MSBuild:Compile</Generator>
@@ -79,7 +80,6 @@
7980
</Compile>
8081
</ItemGroup>
8182
<ItemGroup>
82-
<Compile Include="Model\TabItem.cs" />
8383
<Compile Include="Properties\AssemblyInfo.cs">
8484
<SubType>Code</SubType>
8585
</Compile>

Samples/Databinding/Model/TabItem.cs renamed to Samples/Databinding/ViewModel/TabItem_ViewModel.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
using Syncfusion.Windows.Shared;
22
using Syncfusion.Windows.Tools.Controls;
3-
using System.Windows.Controls;
43

54
namespace Tabcontrol_binding
65
{
7-
public class TabItem : NotificationObject
6+
public class TabItem_ViewModel : NotificationObject
87
{
98
private string header;
10-
private TextBlock content;
9+
private string content;
1110
private string image;
1211
private ImageAlignment imageAlignment = ImageAlignment.LeftOfText;
1312

@@ -17,42 +16,42 @@ public string Header
1716
set
1817
{
1918
header = value;
20-
this.RaisePropertyChanged("Header");
19+
this.RaisePropertyChanged(nameof(Header));
2120
}
2221
}
23-
24-
public TextBlock Content
22+
23+
public string Content
2524
{
2625
get { return content; }
2726
set
2827
{
2928
content = value;
30-
this.RaisePropertyChanged("Content");
29+
this.RaisePropertyChanged(nameof(Content));
3130
}
3231
}
33-
32+
3433
public string Image
3534
{
3635
get { return image; }
3736
set
3837
{
3938
image = value;
40-
this.RaisePropertyChanged("Image");
39+
this.RaisePropertyChanged(nameof(Image));
4140
}
4241
}
4342

44-
43+
4544
public ImageAlignment ImageAlignment
4645
{
4746
get { return imageAlignment; }
4847
set
4948
{
5049
imageAlignment = value;
51-
this.RaisePropertyChanged("ImageAlignment");
50+
this.RaisePropertyChanged(nameof(ImageAlignment));
5251
}
5352
}
5453

55-
public TabItem()
54+
public TabItem_ViewModel()
5655
{
5756

5857
}

Samples/Databinding/ViewModel/ViewModel.cs

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,41 @@ namespace Tabcontrol_binding
88
{
99
public class ViewModel : NotificationObject
1010
{
11-
private ObservableCollection<TabItem> tabItems;
12-
public ObservableCollection<TabItem> TabItems
11+
private ObservableCollection<TabItem_ViewModel> tabItems;
12+
public ObservableCollection<TabItem_ViewModel> TabItems
1313
{
1414
get { return tabItems; }
1515
set
1616
{
1717
tabItems = value;
18-
this.RaisePropertyChanged("TabItems");
18+
this.RaisePropertyChanged(nameof(TabItems));
1919
}
2020
}
2121

2222
public ViewModel()
2323
{
24-
tabItems = new ObservableCollection<TabItem>();
24+
tabItems = new ObservableCollection<TabItem_ViewModel>();
2525
PopulateCollection();
2626
}
2727

2828
public void PopulateCollection()
2929
{
30-
TabItem tabItem1 = new TabItem()
30+
TabItem_ViewModel tabItem1 = new TabItem_ViewModel()
3131
{
3232
Header="tabItem1",
33-
Content= new TextBlock() {
34-
Text = "This is the content of first tabitem.",
35-
HorizontalAlignment = HorizontalAlignment.Center,
36-
VerticalAlignment= VerticalAlignment.Center
37-
},
38-
Image="Images/sync.png" };
39-
TabItem tabItem2 = new TabItem()
33+
Content= "This is the content of first tabitem.",
34+
Image = "Images/sync.png"
35+
};
36+
TabItem_ViewModel tabItem2 = new TabItem_ViewModel()
4037
{
41-
Header="tabItem2", Content= new TextBlock() {
42-
Text = "This is the content of second tabitem.",
43-
HorizontalAlignment = HorizontalAlignment.Center,
44-
VerticalAlignment = VerticalAlignment.Center
45-
},
46-
Image="Images/tabimage.png" };
47-
TabItem tabItem3 = new TabItem()
38+
Header="tabItem2",
39+
Content="This is the content of second tabitem.",
40+
Image = "Images/tabimage.png"
41+
};
42+
TabItem_ViewModel tabItem3 = new TabItem_ViewModel()
4843
{
4944
Header = "tabItem3",
50-
Content = new TextBlock()
51-
{
52-
Text = "This is the content of third tabitem.",
53-
HorizontalAlignment = HorizontalAlignment.Center,
54-
VerticalAlignment = VerticalAlignment.Center
55-
},
45+
Content = "This is the content of third tabitem.",
5646
Image = "Images/sync.png"
5747
};
5848

0 commit comments

Comments
 (0)