Added 38th post.
This commit is contained in:
Родитель
7b14626027
Коммит
1d45347817
|
@ -0,0 +1,9 @@
|
|||
<Application x:Class="UpdateExplicit.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
StartupUri="Window1.xaml"
|
||||
>
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Windows;
|
||||
using System.Data;
|
||||
using System.Xml;
|
||||
using System.Configuration;
|
||||
|
||||
namespace UpdateExplicit
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
|
||||
public partial class App : System.Windows.Application
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
#region Using directives
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Resources;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#endregion
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("UpdateExplicit")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("UpdateExplicit")]
|
||||
[assembly: AssemblyCopyright("Copyright @ 2007")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//In order to begin building localizable applications, set
|
||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
//the line below to match the UICulture setting in the project file.
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
63
38-UpdateExplicit/38UpdateExplicit - Orcas Beta 2/Properties/Resources.Designer.cs
сгенерированный
Normal file
63
38-UpdateExplicit/38UpdateExplicit - Orcas Beta 2/Properties/Resources.Designer.cs
сгенерированный
Normal file
|
@ -0,0 +1,63 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.1318
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace UpdateExplicit.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("UpdateExplicit.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
26
38-UpdateExplicit/38UpdateExplicit - Orcas Beta 2/Properties/Settings.Designer.cs
сгенерированный
Normal file
26
38-UpdateExplicit/38UpdateExplicit - Orcas Beta 2/Properties/Settings.Designer.cs
сгенерированный
Normal file
|
@ -0,0 +1,26 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.1318
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace UpdateExplicit.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version='1.0' encoding='iso-8859-1'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
|
@ -0,0 +1,102 @@
|
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{635BF856-6AD7-437D-9871-A4B505D88F06}</ProjectGuid>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<RootNamespace>UpdateExplicit</RootNamespace>
|
||||
<AssemblyName>UpdateExplicit</AssemblyName>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<OutputType>winexe</OutputType>
|
||||
<MinFrameworkVersionRequired>3.0</MinFrameworkVersionRequired>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Web</InstallFrom>
|
||||
<UpdateEnabled>true</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>false</MapFileExtensions>
|
||||
<ApplicationVersion>1.0.0.*</ApplicationVersion>
|
||||
<IsWebBootstrapper>true</IsWebBootstrapper>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<PublishUrl>Publish\</PublishUrl>
|
||||
<TargetFrameworkVersion>v3.0</TargetFrameworkVersion>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>2.0</OldToolsVersion>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>.\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>.\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="UIAutomationProvider" />
|
||||
<Reference Include="UIAutomationTypes" />
|
||||
<Reference Include="ReachFramework" />
|
||||
<Reference Include="System.Printing" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.IdentityModel" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="Window1.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Window1.xaml.cs">
|
||||
<DependentUpon>Window1.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateExplicit", "UpdateExplicit.csproj", "{635BF856-6AD7-437D-9871-A4B505D88F06}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{635BF856-6AD7-437D-9871-A4B505D88F06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{635BF856-6AD7-437D-9871-A4B505D88F06}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{635BF856-6AD7-437D-9871-A4B505D88F06}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{635BF856-6AD7-437D-9871-A4B505D88F06}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
Двоичный файл не отображается.
|
@ -0,0 +1,63 @@
|
|||
<Window x:Class="UpdateExplicit.Window1"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="UpdateExplicit"
|
||||
SizeToContent="WidthAndHeight"
|
||||
>
|
||||
<Window.Resources>
|
||||
<DataTemplate x:Key="nonEditableEmployee">
|
||||
<StackPanel Margin="2">
|
||||
<TextBlock FontWeight="Bold" Text="{Binding Path=Name}"/>
|
||||
<TextBlock Text="{Binding Path=Title}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="editableEmployee">
|
||||
<StackPanel Margin="2" >
|
||||
<TextBlock FontWeight="Bold" Text="{Binding Path=Name}" />
|
||||
<TextBox Text="{Binding Path=Title, UpdateSourceTrigger=Explicit}" Width="130" x:Name="tb"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<Style TargetType="ListBoxItem" x:Key="lbiStyle">
|
||||
<Setter Property="Height" Value="40" />
|
||||
<Setter Property="ContentTemplate" Value="{StaticResource nonEditableEmployee}" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="ContentTemplate" Value="{StaticResource editableEmployee}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<DataTemplate x:Key="sourceEmployeeTemplate">
|
||||
<StackPanel Height="40">
|
||||
<TextBlock FontWeight="Bold" Text="{Binding Path=Name}" />
|
||||
<TextBlock Text="{Binding Path=Title}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<Style x:Key="title" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Foreground" Value="FireBrick" />
|
||||
<Setter Property="FontWeight" Value="Bold" />
|
||||
<Setter Property="Margin" Value="0,0,0,5" />
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
<Grid Name="root" Margin="40">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Style="{StaticResource title}">Editable Data</TextBlock>
|
||||
<ListBox ItemsSource="{Binding Path=Employees}" ItemContainerStyle="{StaticResource lbiStyle}" IsSynchronizedWithCurrentItem="True" Grid.Row="1" HorizontalAlignment="Left" Width="150" Margin="0,0,10,0" Name="lb" BorderBrush="Black"/>
|
||||
<Button Content="Submit" Click="Submit" Grid.Row="2" Width="75" Margin="0,5,0,0"/>
|
||||
<TextBlock Grid.Column="1" Style="{StaticResource title}">Data in Source</TextBlock>
|
||||
<Border BorderBrush="Black" BorderThickness="1" SnapsToDevicePixels="True" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left">
|
||||
<ItemsControl ItemsSource="{Binding Path=Employees}" ItemTemplate="{StaticResource sourceEmployeeTemplate}" Margin="5"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Window>
|
|
@ -0,0 +1,129 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.ComponentModel;
|
||||
|
||||
|
||||
namespace UpdateExplicit
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Window1.xaml
|
||||
/// </summary>
|
||||
|
||||
public partial class Window1 : System.Windows.Window
|
||||
{
|
||||
|
||||
public Window1()
|
||||
{
|
||||
InitializeComponent();
|
||||
root.DataContext = new MySource();
|
||||
}
|
||||
|
||||
private void Submit(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Employee currentEmployee = (Employee)(lb.Items.CurrentItem);
|
||||
ListBoxItem lbi = (ListBoxItem)(lb.ItemContainerGenerator.ContainerFromItem(currentEmployee));
|
||||
ContentPresenter cp = GetObjectOfTypeInVisualTree<ContentPresenter>(lbi);
|
||||
DataTemplate dt = (DataTemplate)(this.Resources["editableEmployee"]);
|
||||
TextBox tb = (TextBox)(dt.FindName("tb", cp));
|
||||
BindingExpression be = tb.GetBindingExpression(TextBox.TextProperty);
|
||||
be.UpdateSource();
|
||||
}
|
||||
|
||||
private T GetObjectOfTypeInVisualTree<T>(DependencyObject dpob) where T : DependencyObject
|
||||
{
|
||||
int count = VisualTreeHelper.GetChildrenCount(dpob);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
DependencyObject child = VisualTreeHelper.GetChild(dpob, i);
|
||||
T childAsT = child as T;
|
||||
if (childAsT != null)
|
||||
{
|
||||
return childAsT;
|
||||
}
|
||||
childAsT = GetObjectOfTypeInVisualTree<T>(child);
|
||||
if (childAsT != null)
|
||||
{
|
||||
return childAsT;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class MySource
|
||||
{
|
||||
private ObservableCollection<Employee> employees;
|
||||
|
||||
public ObservableCollection<Employee> Employees
|
||||
{
|
||||
get { return employees; }
|
||||
}
|
||||
|
||||
public MySource()
|
||||
{
|
||||
employees = new ObservableCollection<Employee>();
|
||||
employees.Add(new Employee("Matt", "Program Manager"));
|
||||
employees.Add(new Employee("Joan", "Developer"));
|
||||
employees.Add(new Employee("Mark", "Programming Writer"));
|
||||
employees.Add(new Employee("Mary", "Test Lead"));
|
||||
employees.Add(new Employee("Karen", "Developer"));
|
||||
employees.Add(new Employee("George", "Programming Writer"));
|
||||
employees.Add(new Employee("Peter", "Program Manager"));
|
||||
}
|
||||
}
|
||||
|
||||
public class Employee : INotifyPropertyChanged
|
||||
{
|
||||
private string name;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
OnPropertyChanged("Name");
|
||||
}
|
||||
}
|
||||
|
||||
private string title;
|
||||
|
||||
public string Title
|
||||
{
|
||||
get { return title; }
|
||||
set
|
||||
{
|
||||
title = value;
|
||||
OnPropertyChanged("Title");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Employee(string name, string title)
|
||||
{
|
||||
this.name = name;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
{
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<Application x:Class="UpdateExplicit.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
StartupUri="Window1.xaml"
|
||||
>
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Windows;
|
||||
using System.Data;
|
||||
using System.Xml;
|
||||
using System.Configuration;
|
||||
|
||||
namespace UpdateExplicit
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
|
||||
public partial class App : System.Windows.Application
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
#region Using directives
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Resources;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#endregion
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("UpdateExplicit")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("UpdateExplicit")]
|
||||
[assembly: AssemblyCopyright("Copyright @ 2007")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//In order to begin building localizable applications, set
|
||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
//the line below to match the UICulture setting in the project file.
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
|
@ -0,0 +1,70 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.42
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </autogenerated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace UpdateExplicit.Properties
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Resources;
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the Strongly Typed Resource Builder
|
||||
// class via a tool like ResGen or Visual Studio.NET.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
class Resources
|
||||
{
|
||||
|
||||
private static System.Resources.ResourceManager _resMgr;
|
||||
|
||||
private static System.Globalization.CultureInfo _resCulture;
|
||||
|
||||
/*FamANDAssem*/
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((_resMgr == null))
|
||||
{
|
||||
System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Resources", typeof(Resources).Assembly);
|
||||
_resMgr = temp;
|
||||
}
|
||||
return _resMgr;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return _resCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
_resCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
|
@ -0,0 +1,42 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.42
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </autogenerated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace UpdateExplicit.Properties
|
||||
{
|
||||
public partial class Settings : System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
private static Settings m_Value;
|
||||
|
||||
private static object m_SyncObject = new object();
|
||||
|
||||
public static Settings Value
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((Settings.m_Value == null))
|
||||
{
|
||||
System.Threading.Monitor.Enter(Settings.m_SyncObject);
|
||||
if ((Settings.m_Value == null))
|
||||
{
|
||||
try
|
||||
{
|
||||
Settings.m_Value = new Settings();
|
||||
}
|
||||
finally
|
||||
{
|
||||
System.Threading.Monitor.Exit(Settings.m_SyncObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Settings.m_Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version='1.0' encoding='iso-8859-1'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
|
@ -0,0 +1,89 @@
|
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{635BF856-6AD7-437D-9871-A4B505D88F06}</ProjectGuid>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<RootNamespace>UpdateExplicit</RootNamespace>
|
||||
<AssemblyName>UpdateExplicit</AssemblyName>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<OutputType>winexe</OutputType>
|
||||
<MinFrameworkVersionRequired>3.0</MinFrameworkVersionRequired>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Web</InstallFrom>
|
||||
<UpdateEnabled>true</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>false</MapFileExtensions>
|
||||
<ApplicationVersion>1.0.0.*</ApplicationVersion>
|
||||
<IsWebBootstrapper>true</IsWebBootstrapper>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<PublishUrl>Publish\</PublishUrl>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>.\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>.\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="UIAutomationProvider" />
|
||||
<Reference Include="UIAutomationTypes" />
|
||||
<Reference Include="ReachFramework" />
|
||||
<Reference Include="System.Printing" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.IdentityModel" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml" />
|
||||
<Page Include="Window1.xaml" />
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Window1.xaml.cs">
|
||||
<DependentUpon>Window1.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateExplicit", "UpdateExplicit.csproj", "{635BF856-6AD7-437D-9871-A4B505D88F06}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{635BF856-6AD7-437D-9871-A4B505D88F06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{635BF856-6AD7-437D-9871-A4B505D88F06}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{635BF856-6AD7-437D-9871-A4B505D88F06}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{635BF856-6AD7-437D-9871-A4B505D88F06}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
Двоичный файл не отображается.
|
@ -0,0 +1,63 @@
|
|||
<Window x:Class="UpdateExplicit.Window1"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="UpdateExplicit"
|
||||
SizeToContent="WidthAndHeight"
|
||||
>
|
||||
<Window.Resources>
|
||||
<DataTemplate x:Key="nonEditableEmployee">
|
||||
<StackPanel Margin="2">
|
||||
<TextBlock FontWeight="Bold" Text="{Binding Path=Name}"/>
|
||||
<TextBlock Text="{Binding Path=Title}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="editableEmployee">
|
||||
<StackPanel Margin="2" >
|
||||
<TextBlock FontWeight="Bold" Text="{Binding Path=Name}" />
|
||||
<TextBox Text="{Binding Path=Title, UpdateSourceTrigger=Explicit}" Width="130" x:Name="tb"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<Style TargetType="ListBoxItem" x:Key="lbiStyle">
|
||||
<Setter Property="Height" Value="40" />
|
||||
<Setter Property="ContentTemplate" Value="{StaticResource nonEditableEmployee}" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="ContentTemplate" Value="{StaticResource editableEmployee}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<DataTemplate x:Key="sourceEmployeeTemplate">
|
||||
<StackPanel Height="40">
|
||||
<TextBlock FontWeight="Bold" Text="{Binding Path=Name}" />
|
||||
<TextBlock Text="{Binding Path=Title}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<Style x:Key="title" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Foreground" Value="FireBrick" />
|
||||
<Setter Property="FontWeight" Value="Bold" />
|
||||
<Setter Property="Margin" Value="0,0,0,5" />
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
<Grid Name="root" Margin="40">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Style="{StaticResource title}">Editable Data</TextBlock>
|
||||
<ListBox ItemsSource="{Binding Path=Employees}" ItemContainerStyle="{StaticResource lbiStyle}" IsSynchronizedWithCurrentItem="True" Grid.Row="1" HorizontalAlignment="Left" Width="150" Margin="0,0,10,0" Name="lb" BorderBrush="Black"/>
|
||||
<Button Content="Submit" Click="Submit" Grid.Row="2" Width="75" Margin="0,5,0,0"/>
|
||||
<TextBlock Grid.Column="1" Style="{StaticResource title}">Data in Source</TextBlock>
|
||||
<Border BorderBrush="Black" BorderThickness="1" SnapsToDevicePixels="True" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left">
|
||||
<ItemsControl ItemsSource="{Binding Path=Employees}" ItemTemplate="{StaticResource sourceEmployeeTemplate}" Margin="5"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Window>
|
|
@ -0,0 +1,125 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.ComponentModel;
|
||||
|
||||
|
||||
namespace UpdateExplicit
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Window1.xaml
|
||||
/// </summary>
|
||||
|
||||
public partial class Window1 : System.Windows.Window
|
||||
{
|
||||
|
||||
public Window1()
|
||||
{
|
||||
InitializeComponent();
|
||||
root.DataContext = new MySource();
|
||||
}
|
||||
|
||||
private void Submit(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Employee currentEmployee = (Employee)(lb.Items.CurrentItem);
|
||||
ListBoxItem lbi = (ListBoxItem)(lb.ItemContainerGenerator.ContainerFromItem(currentEmployee));
|
||||
ContentPresenter cp = GetObjectOfTypeInVisualTree<ContentPresenter>(lbi);
|
||||
DataTemplate dt = (DataTemplate)(this.Resources["editableEmployee"]);
|
||||
TextBox tb = (TextBox)(dt.FindName("tb", cp));
|
||||
BindingExpression be = tb.GetBindingExpression(TextBox.TextProperty);
|
||||
be.UpdateSource();
|
||||
}
|
||||
|
||||
private T GetObjectOfTypeInVisualTree<T>(DependencyObject dpob) where T : DependencyObject
|
||||
{
|
||||
int count = VisualTreeHelper.GetChildrenCount(dpob);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
DependencyObject child = VisualTreeHelper.GetChild(dpob, i);
|
||||
T childAsT = child as T;
|
||||
if (childAsT != null)
|
||||
{
|
||||
return childAsT;
|
||||
}
|
||||
return GetObjectOfTypeInVisualTree<T>(child);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class MySource
|
||||
{
|
||||
private ObservableCollection<Employee> employees;
|
||||
|
||||
public ObservableCollection<Employee> Employees
|
||||
{
|
||||
get { return employees; }
|
||||
}
|
||||
|
||||
public MySource()
|
||||
{
|
||||
employees = new ObservableCollection<Employee>();
|
||||
employees.Add(new Employee("Matt", "Program Manager"));
|
||||
employees.Add(new Employee("Joan", "Developer"));
|
||||
employees.Add(new Employee("Mark", "Programming Writer"));
|
||||
employees.Add(new Employee("Mary", "Test Lead"));
|
||||
employees.Add(new Employee("Karen", "Developer"));
|
||||
employees.Add(new Employee("George", "Programming Writer"));
|
||||
employees.Add(new Employee("Peter", "Program Manager"));
|
||||
}
|
||||
}
|
||||
|
||||
public class Employee : INotifyPropertyChanged
|
||||
{
|
||||
private string name;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
OnPropertyChanged("Name");
|
||||
}
|
||||
}
|
||||
|
||||
private string title;
|
||||
|
||||
public string Title
|
||||
{
|
||||
get { return title; }
|
||||
set
|
||||
{
|
||||
title = value;
|
||||
OnPropertyChanged("Title");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Employee(string name, string title)
|
||||
{
|
||||
this.name = name;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
{
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 18 KiB |
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 98 KiB |
|
@ -0,0 +1,141 @@
|
|||
# How to update an explicit binding within a template
|
||||
|
||||
![](Images/38mix.bmp)
|
||||
|
||||
Mix07 in Vegas was awesome! I always get pumped up when I meet new customers that are using WPF and loving it! It gives me fuel to come back to rainy Seattle with a smile and extra energized to do my absolute best for WPF!
|
||||
|
||||
In today's sample, I have a ListBox with editable data. When I change the data of one of the items, I want that to be reflected in the source, as usual. However, this time I set my Binding's UpdateSourceTrigger to Explicit, which means I need to make that update by calling the UpdateSource() method on BindingExpression through code. Unfortunately, getting a handle to the BindingExpression in a ListBox scenario is a little tricky with the current bits of WPF, which is why I decided to write this post.
|
||||
|
||||
I will start with a quick explanation of two basic concepts, which are core to the understanding of this problem: Binding Mode and UpdateSourceTrigger. If this is too basic for you, you can skip the next couple of sections and safely jump to "Updating Explicit Bindings."
|
||||
|
||||
## Binding Mode
|
||||
|
||||
WPF Data Binding supports five binding modes (which you can set by using the Mode property of Binding):
|
||||
|
||||
- One way - The data flows from the source to the target only. If you add a Binding to a TextBlock's Text property and don't specify the Mode, it will be one way by default.
|
||||
|
||||
- Two way - The data flows from the source data to the target UI, and the other way around. A Binding on a TextBox's Text property without the Mode specified is two way by default: changes in the source are reflected in the TextBox, and changes typed into the TextBox are also propagated back to the source.
|
||||
|
||||
- One time - Like one way, but the UI doesn't listen to change notifications in the source. You may want to consider using this mode if your source doesn't support property change notifications. If you don't care about changes in the source, setting your binding to one time will make it a little more performant.
|
||||
|
||||
- One way to source - The opposite of one way: the data flows only from the target UI to the source. I have yet to see a good use of this binding mode - the scenarios that require it are quite rare.
|
||||
|
||||
- Default - This is the same as not setting the Mode property at all. The Binding engine will look at the default mode specified at the time the DependencyProperty was registered, and will use that. Therefore, setting the Mode to Default will not mean the same thing for all DependencyProperties. For example, as I mentioned before, TextBlock's Text has a default mode of one way, while the TextBox's Text has a default of two way.
|
||||
|
||||
But how do we know the default Binding Mode of a DependencyProperty? How can we set a default Binding Mode when we define a new DependencyProperty?
|
||||
|
||||
<a href="http://www.red-gate.com/products/reflector/">.NET Reflector</a> is your friend. With reflector, search for TextBox and look at the source for the static constructor (.cctor()). Here, you will be able to find the code used for registering the TextProperty DP:
|
||||
|
||||
TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(TextBox), new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.Journal | FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback(TextBox.OnTextPropertyChanged), new CoerceValueCallback(TextBox.CoerceText), true, UpdateSourceTrigger.LostFocus));
|
||||
|
||||
Notice that a parameter is passed to the Register method indicating the default Binding Mode: FrameworkPropertyMetadataOptions.BindsTwoWayByDefault. If you use reflector to look at the registration for TextBlock's Text DP, you will see that no such value is passed, in which case we assume the binding is one way by default.
|
||||
|
||||
It is not possible to make the binding one way to source or one time by default (we couldn't think of any compelling user scenarios that would justify increasing the complixity of the API). However, it is possible to say that you don't want the DP to support data binding at all - to do this, simply pass FrameworkPropertyMetadataOptions.NotDataBindable as a parameter.
|
||||
|
||||
## Binding UpdateSourceTrigger
|
||||
|
||||
In the case of a binding that propagates values from the target to the source (Mode = TwoWay or OneWayToSource), we allow you to specify how you want that update to be triggered. There are three ways to cause the changes to propagate to the source (which you can set by using the UpdateSourceTrigger property of Binding):
|
||||
|
||||
- LostFocus - The value will be updated when the element loses focus. This is the default behavior for TextBox (notice that UpdateSourceTrigger.LostFocus is specified when the Text dependency property was registered). When you type something in a TextBox, that value will be updated to the source when you change focus to some other element.
|
||||
|
||||
- PropertyChanged - The value is updated every time it changes. In the TextBox scenario, the value will be updated every time you type a new character.
|
||||
|
||||
- Explicit - The target value if not updated until you explicitly call "UpdateSource()" on the BindingExpression.
|
||||
|
||||
## Updating Explicit Bindings
|
||||
|
||||
In today's sample, I started by defining a source object (MySource) with a property Employees of type ObservableCollection<Employee>. Employee is a class that contains two properties: Name and Title, both of type string. The code for defining this source is straight forward, so I won't show it here.
|
||||
|
||||
Then I added a ListBox to my XAML file that is bound to the Employees collection, and I added a Style for its items:
|
||||
|
||||
<Window.Resources>
|
||||
<DataTemplate x:Key="nonEditableEmployee">
|
||||
<StackPanel Margin="2">
|
||||
<TextBlock FontWeight="Bold" Text="{Binding Path=Name}"/>
|
||||
<TextBlock Text="{Binding Path=Title}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="editableEmployee">
|
||||
<StackPanel Margin="2" >
|
||||
<TextBlock FontWeight="Bold" Text="{Binding Path=Name}" />
|
||||
<TextBox Text="{Binding Path=Title, UpdateSourceTrigger=Explicit}" Width="130" x:Name="tb"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<Style TargetType="ListBoxItem" x:Key="lbiStyle">
|
||||
<Setter Property="Height" Value="40" />
|
||||
<Setter Property="ContentTemplate" Value="{StaticResource nonEditableEmployee}" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="ContentTemplate" Value="{StaticResource editableEmployee}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
<ListBox ItemsSource="{Binding Path=Employees}" ItemContainerStyle="{StaticResource lbiStyle}" IsSynchronizedWithCurrentItem="True" (...) Name="lb"/>
|
||||
<Button Content="Submit" Click="Submit" (...) />
|
||||
|
||||
In the Style for ListBoxItems, I am specifying that I want the DataTemplate applied to each of the items to be "nonEditableEmployee" except when the item is selected, in which case I want to use "editableEmployee". Both DataTemplates display the Name and Title of the Employee, the only difference is that "editableEmployee" displays the Title using a TextBox instead of a TextBlock. So, when the user selects an employee in the ListBox, that employee's Title becomes editable.
|
||||
|
||||
Below the ListBox I have a Submit Button. If I click on this Button after editing some data in the ListBox, I want that data to be submitted to the source. However, if I change the data in the ListBox and don't click on the Button, I don't want the source to be modified. Notice that I set the UpdateSourceTrigger of editable Title's Binding to Explicit.
|
||||
|
||||
To achieve this behavior, I need to call the UpdateSource() on the BindingExpression's instance. Getting this instance is a little tricky, so let's think about it for a minute. The best way to think about this is by starting from the end, and walking backwards. Utimately, this is the code I want to write (assuming "be" is the BindingExpression instance, and "tb" is the TextBox's instance):
|
||||
|
||||
BindingExpression be = tb.GetBindingExpression(TextBox.TextProperty);
|
||||
be.UpdateSource();
|
||||
|
||||
As you can see, in order to get the BindingExpression for the Binding in the TextBox's Text property, I need to have a handle to that TextBox. Traversing the DataTemplate to get to the TextBox won't give me the actual instance, it will only give me the FrameworkElementFactory used to create the TextBox instance. Fortunately, DataTemplate has a FindName method that, given the instance of the object the template is applied to, will give you a particular named part within its visual tree. So, assuming "cp" is the object the DataTemplate is applied to, this is the code I would like to write to get the actual TextBox:
|
||||
|
||||
DataTemplate dt = (DataTemplate)(this.Resources["editableEmployee"]);
|
||||
TextBox tb = (TextBox)(dt.FindName("tb", cp));
|
||||
|
||||
We're getting close. The next step is to figure out how to get to the element the DataTemplate is applied to. A DataTemplate is always applied to a ContentPresenter, which is an element present in the visual tree of every ContentControl. Since every item in the ListBox is wrapped with a ListBoxItem (which is a ContentControl), I simply have to get to the ContentPresenter instance in the ControlTemplate for the currently selected ListBoxItem. Here is what I did:
|
||||
|
||||
Employee currentEmployee = (Employee)(lb.Items.CurrentItem);
|
||||
ListBoxItem lbi = (ListBoxItem)(lb.ItemContainerGenerator.ContainerFromItem(currentEmployee));
|
||||
ContentPresenter cp = GetObjectOfTypeInVisualTree<ContentPresenter>(lbi);
|
||||
|
||||
"GetObjectOfTypeInVisualTree" is a simple recursive method that walks the visual tree of an object (in this case, the current ListBoxItem) and returns the first element matching the type specified by the generic parameter (in this case ContentPresenter). Here is the complete code:
|
||||
|
||||
private void Submit(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Employee currentEmployee = (Employee)(lb.Items.CurrentItem);
|
||||
ListBoxItem lbi = (ListBoxItem)(lb.ItemContainerGenerator.ContainerFromItem(currentEmployee));
|
||||
ContentPresenter cp = GetObjectOfTypeInVisualTree<ContentPresenter>(lbi);
|
||||
|
||||
DataTemplate dt = (DataTemplate)(this.Resources["editableEmployee"]);
|
||||
TextBox tb = (TextBox)(dt.FindName("tb", cp));
|
||||
|
||||
BindingExpression be = tb.GetBindingExpression(TextBox.TextProperty);
|
||||
be.UpdateSource();
|
||||
}
|
||||
|
||||
private T GetObjectOfTypeInVisualTree<T>(DependencyObject dpob) where T : DependencyObject
|
||||
{
|
||||
int count = VisualTreeHelper.GetChildrenCount(dpob);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
DependencyObject child = VisualTreeHelper.GetChild(dpob, i);
|
||||
T childAsT = child as T;
|
||||
if (childAsT != null)
|
||||
{
|
||||
return childAsT;
|
||||
}
|
||||
childAsT = GetObjectOfTypeInVisualTree<T>(child);
|
||||
if(childAsT != null)
|
||||
{
|
||||
return childAsT;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
This code is not only useful for submitting explicit bindings; it is useful for any scenario where you need to get to the instance of some element in your DataTemplate. It should be pretty easy to tweak this sample to suit your needs.
|
||||
|
||||
We do realize that this scenario is quite hard to implement, and we know it's not that uncommon. We would like to make it easier, but unfortunately we will not be able to make that happen in the next release. At least for now you have a sample solution that should help you solve most scenarios. Hopefully we will have a chance to fix this in the platform in the near future.
|
||||
|
||||
Below is a screenshot of the final application. The ListBox on the right is bound to the same source. I added it to this sample so you can see when the source changes.
|
||||
|
||||
![](Images/38UpdateExplicit.png)
|
Загрузка…
Ссылка в новой задаче