Issue binding grouped data to cvs for semantic zoom - c#

I'm having some trouble getting my semantic zoom bind correctly to my CollectionViewSource. I'm pretty new to MVVM, so I'm not sure i have stuff setup correctly.
View Model
private async void GetData()
{
// Simulate pulling data from api
string response;
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(#"ms-appx:///DesignData/GetLive.json"));
using (StreamReader sRead = new StreamReader(await file.OpenStreamForReadAsync()))
response = await sRead.ReadToEndAsync();
// Deserialize data to class
LiveStreamModel liveGames = JsonConvert.DeserializeObject<LiveStreamModel>(response);
Schedules = liveGames.schedule;
// Group data by event
var groupData = liveGames.schedule.GroupBy(a => a.#event);
// Set cvs source to grouped data
ScheduleSource = new CollectionViewSource() { IsSourceGrouped = true, Source = groupData };
}
private CollectionViewSource scheduleSource;
public CollectionViewSource ScheduleSource
{
get
{
return scheduleSource;
}
set
{
scheduleSource = value;
RaisePropertyChanged("ScheduleSource");
}
}
View
Page.Resources>
<DataTemplate x:Key="ZoomedInTemplate">
<StackPanel Orientation="Horizontal" MinWidth="200" Margin="12,6,0,6">
<!--<Image Source="{Binding ImagePath}" Height="80" Width="80"/>-->
<StackPanel Margin="20,0,0,0">
<TextBlock Text="{Binding homeTeam}" Style="{StaticResource BaseTextBlockStyle}"/>
<TextBlock Text="{Binding awayTeam}" TextWrapping="Wrap" HorizontalAlignment="Left" Width="300"
Style="{StaticResource BodyTextBlockStyle}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="ZoomedInGroupHeaderTemplate">
<TextBlock Text="{Binding event}" Foreground="{ThemeResource ApplicationForegroundThemeBrush}"
Style="{StaticResource SubtitleTextBlockStyle}"/>
</DataTemplate>
<DataTemplate x:Key="ZoomedOutTemplate">
<TextBlock Text="{Binding event}" Style="{StaticResource SubtitleTextBlockStyle}"/>
</DataTemplate>
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<SemanticZoom x:Name="GetLiveZoom" >
<SemanticZoom.ZoomedInView>
<GridView x:Name="GetLiveGrid" ItemsSource="{Binding ScheduleSource.View}" ItemTemplate="{StaticResource ZoomedInTemplate}" SelectionMode="Single"
ScrollViewer.IsHorizontalScrollChainingEnabled="False">
<GridView.GroupStyle>
<GroupStyle HeaderTemplate="{StaticResource ZoomedInGroupHeaderTemplate}" />
</GridView.GroupStyle>
</GridView>
</SemanticZoom.ZoomedInView>
<SemanticZoom.ZoomedOutView>
<GridView x:Name="GetLiveList" ItemsSource="{Binding ScheduleSource.View.CollectionGroups}" ItemTemplate="{StaticResource ZoomedOutTemplate}" SelectionMode="None"
ScrollViewer.IsVerticalScrollChainingEnabled="False"/>
</SemanticZoom.ZoomedOutView>
</SemanticZoom>
</Grid>
When debugging, my data is getting grouped properly by #event, but setting the source of the cvs to the grouped data and binding that to the semantic zoom control results in nothing showing up.

You need to fix the following data binding:
1) For ZoomedInGroupHeaderTemplate, because the Source is grouped data, so if you want to show the group name in ZoomedInView, set data binding for Key property:
<DataTemplate x:Key="ZoomedInGroupHeaderTemplate">
<TextBlock Text="{Binding Key}" Foreground="{ThemeResource ApplicationForegroundThemeBrush}"
Style="{StaticResource SubtitleTextBlockStyle}"/>
</DataTemplate>
2) For ZoomedOutTemplate, the Source is ICollectionView.CollectionGroups, ref MSDN -> ICollectionViewGroup interface
We need to use ICollectionViewGroup.Group property to get group name in ZoomedOutView:
<DataTemplate x:Key="ZoomedOutTemplate">
<TextBlock Text="{Binding Group.Key}" Style="{StaticResource SubtitleTextBlockStyle}"/>
</DataTemplate>
Check my completed sample in Github
Screenshot for ZoomedInView:
Screenshot for ZoomedOutView:

Related

Binding parameter to a nested ListView using SelectedItem

I'm pretty new to coding in c# and I'm trying on a wpf app to transfer data between different folders.
To visualize the folders and subfolders I've got a tabcontrol with different mainfolders, and under each tab a ListView with information on the subfolders.
All data is gathered in a BindingList 'Klinieken', which is filled with objects 'Kliniek' (mainfolders) which contains objects 'Patient' (subfolders) which is filled with information about said folder. Here is the .xaml file for the mainwindow:
<Grid x:Name="LayoutRoot" Background="#555555">
<Grid.RowDefinitions>
<RowDefinition Height="420" />
<RowDefinition Height="116" />
</Grid.RowDefinitions>
<Grid x:Name="KliniekTabs" Background="#555555" Grid.Row="0" Margin="10 10 10 10">
<TabControl ItemsSource="{Binding Klinieken}"
SelectedItem="{Binding BronKliniek}"
TabStripPlacement="Top">
<TabControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding KliniekNaam}" />
</DataTemplate>
</TabControl.ItemTemplate>
<TabControl.ContentTemplate>
<DataTemplate>
<ListView ItemsSource="{Binding Path=Patienten}"
SelectedItem="{Binding Path=SelectedPatient}">
<ListView.Resources>
<Style TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="HorizontalContentAlignment" Value="Left"/>
</Style>
</ListView.Resources>
<ListView.View>
<GridView>
<GridViewColumn Header="Patientnaam"
Width="250"
DisplayMemberBinding="{Binding PatientNaam}"/>
<GridViewColumn Header="Zisnr"
Width="250"
DisplayMemberBinding="{Binding PatientZis}"/>
<GridViewColumn Header="Aanmaakdatum"
Width="250"
DisplayMemberBinding="{Binding AanmaakDatum}"/>
</GridView>
</ListView.View>
</ListView>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
</Grid>
<Grid x:Name="WindowControls" Background="#777777" Grid.Row="1" Margin="100 5 100 10">
<StackPanel Orientation="Vertical">
<Label Margin="-80 0 0 0" HorizontalAlignment="Center">Doel kliniek</Label>
<ComboBox ItemsSource="{Binding Path=Klinieken}"
x:Name="doelKliniekDD"
SelectedItem="{Binding DoelKliniek}"
Margin="-120 0 0 0"
HorizontalAlignment="Center">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=KliniekNaam}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<StackPanel Orientation="Horizontal" Margin="20 0 0 0" Height="50" VerticalAlignment="Bottom" HorizontalAlignment="Center">
<Button Height="25" Style="{StaticResource Button_Orange}" Command="{Binding TransferButtonCommand}" CommandParameter="{Binding ElementName=window, Mode=OneWay}" Margin="0 0 10 0">Transfer</Button>
<Button Height="25" Style="{StaticResource Button_Orange}" Command="{Binding CopyButtonCommand}" CommandParameter="{Binding ElementName=window, Mode=OneWay}" Margin="10 0 20 0">Kopieer</Button>
<Button Height="25" Style="{StaticResource Button_Grey}" Command="{Binding CloseCommand}" CommandParameter="{Binding ElementName=window, Mode=OneWay}" Margin="20 0 0 0">Cancel</Button>
</StackPanel>
</StackPanel>
</Grid>
</Grid>
And here is the MainViewModel that is referenced in the .xaml:
//attributen
string monacoDirectory;
List<string> aanwezigeClinics;
Installation installation;
//constructor
public MainViewModel()
{
monacoDirectory = ConfigurationManager.AppSettings["monacoDirectory"];
aanwezigeClinics = new List<string>(Directory.GetDirectories(monacoDirectory, "*", SearchOption.TopDirectoryOnly));
aanwezigeClinics.Remove(monacoDirectory + #"\defaults");
aanwezigeClinics.Remove(monacoDirectory + #"\physics");
installation = new Installation(aanwezigeClinics);
Klinieken = new BindingList<Kliniek>();
foreach (var kliniek in installation.Klinieken)
{
Klinieken.Add(kliniek);
}
}
private Kliniek _doelKliniek;
private Kliniek _bronKliniek;
private Patient _selectedPatient;
private BindingList<Kliniek> _klinieken = new BindingList<Kliniek>();
public BindingList<Kliniek> Klinieken
{
get { return _klinieken; }
set { _klinieken = value; }
}
public Kliniek DoelKliniek
{
get { return _doelKliniek; }
set
{
_doelKliniek = value;
OnPropertyChanged();
}
}
public Kliniek BronKliniek
{
get { return _bronKliniek; }
set
{
_bronKliniek = value;
OnPropertyChanged();
}
}
public Patient SelectedPatient
{
get { return _selectedPatient; }
set
{
_selectedPatient = value;
MessageBox.Show("hoi");
OnPropertyChanged();
}
}
The data shows up in the gui just fine, which i was quite happy with. And using SelectedItem on the TabControl and the ComboBox i use later worked out beautifully aswell, but I just cant seem to get the SelectedItem on the ListView to work. I have added a button to test the output of the fields and SelectedPatient always returns as null.
If i check the 'Live Visual Tree' in VS and go to the properties of the ListView i can see the Patient as SelectedItem, so that tells me its not a selection but a binding problem. Furthermore ive tried to google for nested bindings, but the suggestions there didnt change anything about my situation.
Is a nested binding like this possible, or should i take a whole different approach?
Had a similar problem quite a while ago. The suggestions below solved it for me at the time.
Use SelectedValue instead of SelectedItem. This is because SelectedItem doesn't change until the control has been validated. SelectedValue changes whenever the user selects an item. The code you could use is as follows:
SelectedValue="{Binding BronKliniek, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
For the button part, try to provide CommandParameter="{Binding}" instead of CommandParameter="{Binding ElementName=window, Mode=OneWay}". This way, you'll get the value of the current DataContext of the button, which you can then use to extract the data you want from this DataContext.

Display database to listbox

I have a listbox containing a choice of text answers taken from the database and containing html languages, such as: <p>, etc. I want to display it so that the html language is not displayed. I tried to display it in the webview, but <p>, etc. is still visible.
XAML:
<ListBox Name="ListOption" Grid.Row="1" Margin="10,20,10,0" Height="auto" xmlns:m="using:KipinSchool_Win10.TryoutData.Models" SelectionChanged="ListAlternatives_SelectionChanged" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<ListBox.ItemTemplate>
<DataTemplate x:DataType="m:DBOption">
<StackPanel Orientation="Horizontal">
<WebView Margin="10,10,10,10" local:MyProperties.HtmlString="{Binding Option}" MinHeight="40" MaxHeight="300" HorizontalAlignment="Stretch" Tag="{Binding OID}"/>
<TextBlock Text="{Binding Option}" Tag="{Binding OID}" FontSize="19"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Code:
string strA = #"SELECT DISTINCT* FROM DBOption WHERE QID='" + question[0] + "'";
var alternative = objConn.Prepare(strA);
ObservableCollection<DBOption> Items = new ObservableCollection<DBOption>();
int i = 0;
while (alternative.Step() == SQLiteResult.ROW)
{
Items.Add(new DBOption(alternative[0].ToString(), alternative[1].ToString(), alternative[2].ToString(), alternative[3].ToString()));
}
Binding myBinding = new Binding();
myBinding.Source = Items;
ListOption.SetBinding(ItemsControl.ItemsSourceProperty, myBinding);
How to handle it?
I tried to display it in the webview, but etc. is still visible. XAML:
I could reproduce your issue, the problem is that you have not set width and height property for WebView. And html string does not contain the content height. So the WebView will not display correctly. Please modify the code like the following.
<ListBox.ItemTemplate>
<DataTemplate >
<StackPanel Orientation="Horizontal">
<WebView Margin="10,10,10,10"
local:MyProperties.HtmlString="{Binding Option}"
Height="400" Width="200"
HorizontalAlignment="Stretch"
Tag="{Binding OID}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>

Binding imported files to ListView

I'm trying to bind a list of my class into a ListView. I've tried many issues.
There is my c# Code witch show how I define:
public MainWindow()
{
InitializeComponent();
timer.Interval = TimeSpan.FromSeconds(1); // L’intervalle entre chaque tick du timer sera d’une seconde
timer.Tick += new EventHandler(timer_Tick); // A chaque tick, on déclenche l’évènement timer_Tick
MyMP3LIST = new List<ListGrid>();
ListM.DataContext = MyMP3LIST; // ListM = ListView name
// I've tried : ListM.ItemSource = MyMP3LIST;
}
When try to bind :
ListGrid l = new ListGrid(); // My Class
l.IconUri = imagemp3.Source;
l.Title = Ftitle;
l.Length = duration;
l.Album = Falbum;
l.Composer = Fcomposer;
l.Path = openFileDialog1.FileName;
MyMP3LIST.Add(l);
My XAML:
<ListView x:Name="ListM" Width="Auto" ItemsSource="{Binding MyMP3LIST}"
Margin="-3,-0.877,-4,-15.925" SelectionChanged="ListM_SelectionChanged">
Just the first imported file is display into the ListView.
After populating MyMP3LIST Change this:
ListM.DataContext = MyMP3LIST;
To this:
this.DataContext = MyMP3LIST;
And also change this:
<ListView x:Name="ListM" Width="Auto" ItemsSource="{Binding MyMP3LIST}" ../>
To this:
<ListView x:Name="ListM" Width="Auto" ItemsSource="{Binding}" .../>
Also in your ListView you need ItemTemplate to show data. For example:
<ListView x:Name="ListM" Width="Auto" ItemsSource="{Binding}" ...>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Title}" />
<TextBlock Text="{Binding Album}" />
...
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
<ListView>
Edit: Based on your comments that you said you want to add item with an OpenFileDialog and you want to update your ListView, MyMP3LIST should be ObservableCollection:
ObservableCollection<ListGrid> MyMP3LIST = new ObservableCollection<ListGrid>();
Sorry for the double answer but comments do not allow code.
This is just a sample so I'm not sure if all the properties are exact, but it should look like this:
<ListView Grid.Row="0" Grid.Column="0" ItemsSource="{Binding Path=YourCollection, Mode=OneWay}"
SelectedItem="{Binding Path=YourSelectedItem, Mode=TwoWay}"
Margin="0"
>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel>
<WrapPanel>
<TextBlock Text="{Binding Path=FieldName1}" />
<TextBlock Text="{Binding Path=FieldName2}" />
</WrapPanel>
<WrapPanel>
<TextBlock Text="{Binding Path=FieldName3}" />
<TextBlock Text="{Binding Path=FieldName4}" />
</WrapPanel>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
The Item template can be defined with any kind of WPF control you like for your properties.

Binding data in Hub Control in Windows universal apps with list items

Hello I have list defined as follows
public class Article
{
public string title { get; set; }
public string author { get; set; }
public string content { get; set; }
}
public static List<Article> articles = new List<Article>();
I use a async method to get xml data from server and parse it.
private async void Button_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
{
//Progress Bar
prg.Visibility = Visibility.Visible;
string xml = string.Empty;
Uri url = new Uri("http://someurl.com/someting.php");
HttpClient httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Accept", "text/html,application/xhtml+xml,application/xml");
var response = await httpClient.GetAsync(url);
using (var responseStream = await response.Content.ReadAsStreamAsync())
using (var streamReader = new StreamReader(responseStream))
{
xml = streamReader.ReadToEnd();
}
try
{
Debug.WriteLine("Parsing to start");
string eve = "article";
XDocument loadedData = XDocument.Parse(xml);
foreach (var item in loadedData.Descendants(eve))
{
try
{
Article c = new Article();
c.title = item.Element("title").Value;
c.author = item.Element("author").Value;
c.content = item.Element("content").Value;
articles.Add(c);
}
catch
{
Debug.WriteLine("Failed");
}
}
Debug.WriteLine("About to add items");
articlelist.DataContext = articles;
Debug.WriteLine("Items added");
}
catch
{
Debug.WriteLine("Parsing Failed");
}
prg.Visibility = Visibility.Collapsed;
}
Below is the xaml UI elments
<Page
x:Class="Airtrixz.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Airtrixz"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<ProgressBar Grid.Row="0" IsIndeterminate="True" Foreground="{StaticResource PhoneAccentBrush}" VerticalAlignment="Top" Height="16" x:Name="prg" Visibility="Collapsed"/>
<TextBlock Text="Airtrixz" Margin="10,0,0,0" FontSize="30"/>
<Hub Margin="0,50" Foreground="White">
<HubSection Header="posts" x:Name="articlelist" >
<DataTemplate>
<StackPanel Background="Transparent">
<TextBlock Foreground="White" Text="{Binding title}" Height="25" />
<TextBlock Foreground="White" Text="{Binding author}" Height="25"/>
<TextBlock Foreground="White" Text="{Binding content}" Height="25"/>
</StackPanel>
</DataTemplate>
</HubSection>
</Hub>
<Button Width="100" Margin="10,10,0,0" VerticalAlignment="Bottom" Height="50" Tapped="Button_Tapped" Content="Load"/>
</Grid>
</Page>
Doing articlelist.DataContext=articles seems to be fine. But no list items are being displayed and it gives the following error for title, content and author properties in HubSection
Error: BindingExpression path error: 'title' property not found on 'System.Collections.Generic.List1[[Airtrixz.MainPage+Article, Airtirxz.WindowsPhone, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. BindingExpression: Path='title' DataItem='System.Collections.Generic.List1[[Airtrixz.MainPage+Article, Airtirxz.WindowsPhone, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'; target element is 'Windows.UI.Xaml.Controls.TextBlock' (Name='null'); target property is 'Text' (type 'String')
Could anyone give me a solution for this?
Since your HubSection's DataTemplate is a StackPanel, it will only display a single object, not an entire list of articles. For that you need a ListBox or a ListView. This is why you are getting the Bindings error; it is trying to find the 'title' property on your List, which of course is not there. Try this:
<Hub Margin="0,50" Foreground="White">
<HubSection Header="posts" x:Name="articlelist" >
<DataTemplate>
<ListView ItemsSource="{Binding}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Background="Transparent">
<TextBlock Foreground="White" Text="{Binding title}" Height="25" />
<TextBlock Foreground="White" Text="{Binding author}" Height="25"/>
<TextBlock Foreground="White" Text="{Binding content}" Height="25"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</DataTemplate>
</HubSection>
</Hub>
This will bind the ItemsSource of the ListView to the DataContext of the HubSection, which you are setting to articles in your Button_Tapped callback, so it should all work. post a reply either way, and I can try to help debug more.
Not sure if I should put it here as an answer as I've never used Hub control but my guess would be that HubSections will have to be populate like this:
<ItemsControl ItemsSource="{Binding}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<HubSection Header="posts">
<DataTemplate>
<StackPanel Background="Transparent">
<TextBlock Foreground="White" Text="{Binding title}" Height="25" />
<TextBlock Foreground="White" Text="{Binding author}" Height="25"/>
<TextBlock Foreground="White" Text="{Binding content}" Height="25"/>
</StackPanel>
</DataTemplate>
</HubSection>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

wpf check list box

I m new to wpf.In order to get check list box functionality ,I have added below xaml to my code,but there is no output in my screen.only blank,what it could be?
<TabItem Header="Samples" >
<ListBox Margin="10" Width="373" Height="236">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="MyText"/>
<CheckBox IsChecked="False"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</TabItem>
just have a look at this basic sample
http://merill.net/2009/10/wpf-checked-listbox/
List box is a bit wired for such task..Have a look at ItemsControl.
Here is the code i use:
<ItemsControl
ItemsSource="{Binding ***}" IsTabStop="False">
<ItemsControl.ItemTemplate>
<DataTemplate>
<CheckBox
Content="{Binding Name}"
IsChecked="{Binding IsSelected}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Replace your code with this
<TabItem Header="Roles" >
<ListBox Margin="10" Width="373" Height="236">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="MyText"/>
<CheckBox IsChecked="False"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBoxItem>Hi</ListBoxItem>
</ListBox>
</TabItem>
and tell us if it still shows blank
Better still, just use the new CheckListBox control in the Extended WPF Toolkit
http://wpftoolkit.codeplex.com/wikipage?title=CheckListBox&referringTitle=Home
This might help
1.Inorder to work datatemplate you must specify itemsource, here i have bounded a Stateslist a collection of items into it.
2.Also set the Datacontext to ViewModel or the CodeBehind as datacontext.
3.Datacontext will distribute the StateList properties collection to the listbox itemsource
using codebehind -
public Window1()
{
InitializeComponent();
this.DataContext = this;
LoadData();
}
using viewmodel
public Window1()
{
InitializeComponent();
DataContext = new Window1ViewModel();
LoadData();
}
//MyItemsource Property for listbox
private ObservableCollection<States> _stateslist;
public ObservableCollection<States> StatesList
{
get { return _stateslist; }
set
{
_stateslist = value;
RaisePropertyChanged(() => StatesList);
}
}
// Sample Data Loading
public void LoadData()
{
StatesList = new ObservableCollection<States>();
StatesList.Add(new States
{
StateName = "Kerala"
});
StatesList.Add(new States
{
StateName = "Karnataka"
});
StatesList.Add(new States
{
StateName = "Goa"
});
}
Window1.Xaml
<ListBox ItemsSource="{Binding StatesList}" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<CheckBox IsChecked="{Binding IsSelected"} Content="{Binding StateName}" />
<TextBox Text="{Binding TextBoxValue}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Check this out it isworking..you are using TabItem but you didnt define it in TabControl
<TabControl>
<TabItem Header="Tab1">
<ListBox Margin="10" Width="373" Height="236">
<ListBox.Items>
<StackPanel Orientation="Horizontal">
<TextBlock Text="MyText"/>
<CheckBox IsChecked="False"/>
</StackPanel>
</ListBox.Items>
</ListBox>
</TabItem>
</TabControl>
If you are new in WPF use XamlPadX it will give you great help to practice out on it..

Categories