Click here to Skip to main content
15,895,777 members
Articles / Desktop Programming / Windows Forms

User Settings Applied

Rate me:
Please Sign up or sign in to vote.
4.95/5 (136 votes)
5 Sep 2013CPOL10 min read 544.7K   7.5K   490  
Simplifying the .NET User Configuration for Windows Forms and WPF
<win:BaseWindow
	x:Class="Itenso.Solutions.Community.ConfigurationWindowsDemo.ListViewSettingsWindow"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:win="clr-namespace:Itenso.Solutions.Community.ConfigurationWindowsDemo"
	DataContext="{Binding RelativeSource={RelativeSource Self}}"
	Title="ListView Settings"
	Width="600"
	Height="400"
	MinWidth="500"
	MinHeight="300"
	Icon="/ConfigurationWindowsDemo;component/App.ico">
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition
				Height="Auto" />
			<RowDefinition />
			<RowDefinition
				Height="Auto" />
		</Grid.RowDefinitions>
		<TextBlock
			Text="Please change column order/width, press OK and re-open the window. Cancel to suppress settings save."
			Padding="5"
			Background="{x:Static SystemColors.ControlDarkBrush}"
			Grid.Row="0" />
		<ListView
			Name="CustomerListView"
			Grid.Row="1"
			ItemsSource="{Binding Customers}">
			<ListView.View>
				<GridView
					AllowsColumnReorder="True">
					<GridViewColumn
						Header="First Name">
						<GridViewColumn.CellTemplate>
							<DataTemplate>
								<TextBlock
									Text="{Binding FirstName}" />
							</DataTemplate>
						</GridViewColumn.CellTemplate>
					</GridViewColumn>

					<GridViewColumn
						Header="Last Name">
						<GridViewColumn.CellTemplate>
							<DataTemplate>
								<TextBlock
									Text="{Binding LastName}" />
							</DataTemplate>
						</GridViewColumn.CellTemplate>
					</GridViewColumn>

					<GridViewColumn
						Header="Street">
						<GridViewColumn.CellTemplate>
							<DataTemplate>
								<TextBlock
									Text="{Binding Street}" />
							</DataTemplate>
						</GridViewColumn.CellTemplate>
					</GridViewColumn>

					<GridViewColumn
						Header="City">
						<GridViewColumn.CellTemplate>
							<DataTemplate>
								<TextBlock
									Text="{Binding City}" />
							</DataTemplate>
						</GridViewColumn.CellTemplate>
					</GridViewColumn>

					<GridViewColumn
						Header="ZipCode">
						<GridViewColumn.CellTemplate>
							<DataTemplate>
								<TextBlock
									Text="{Binding ZipCode}" />
							</DataTemplate>
						</GridViewColumn.CellTemplate>
					</GridViewColumn>

				</GridView>
			</ListView.View>

		</ListView>

		<StackPanel
			Orientation="Horizontal"
			VerticalAlignment="Bottom"
			HorizontalAlignment="Right"
			Grid.Row="2">
			<Button
				Content="Cancel"
				Margin="5"
				Width="100"
				Click="ButtonCancel" />
			<Button
				Content="OK"
				Margin="5"
				Width="100"
				Click="ButtonOk" />
		</StackPanel>
	</Grid>
</win:BaseWindow>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Switzerland Switzerland
👨 Senior .NET Software Engineer

🚀 My Open Source Projects
- Time Period Library 👉 GitHub
- Payroll Engine 👉 GitHub

Feedback and contributions are welcome.



Comments and Discussions