вторник, 10 мая 2011 г.

Working Example of Web.config for WCF-Service IIS hosted for Silverlight with Windows Authentication


<?xml version="1.0" encoding="UTF-8"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0" />
        <customErrors mode="RemoteOnly" />
        <authentication mode="Windows" />
      </system.web>
    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
        <services>
            <service name="web4.TsService">
              <endpoint address="" binding="basicHttpBinding" bindingConfiguration="web4.TsService.customBinding0" contract="web4.TsService">
                  <identity>
                    <dns value="MyDomainName" />
                  </identity>
                  </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
              <host>
                <baseAddresses>
                  <add baseAddress="http://MyServerName.MyDomainName:8080/tfs/web4/"/>
                </baseAddresses>
              </host>
            </service>
        </services>
        <bindings>
            <basicHttpBinding>
                <binding name="web4.TsService.customBinding0">
                  <security mode="TransportCredentialOnly">
                    <transport clientCredentialType="Ntlm"></transport>
                  </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client />
    </system.serviceModel>
</configuration>

среда, 4 мая 2011 г.

Silverlight 3 HierarchicalDataTemplate


I was able to get it work!

1) First treaky thing : You must find where HierarchicalDataTemplate is living
xmlns:xctrl="clr-namespace:System.Windows;assembly=System.Windows.Controls"

2) In silverlight you should explicitly point thе template. While in WPF the way you move is type recognition in hierarhy. There is DataType property for HierarchicalDataTemplate in WPF.
Here in silverlight ItemTemplate for ChildTemplate. For child use DataTemplate or HierarhicalDataTemplate




<UserControl x:Class="TestSilverlight5.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:xctrl="clr-namespace:System.Windows;assembly=System.Windows.Controls"
    mc:Ignorable="d"
    d:DesignHeight="337" d:DesignWidth="591" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" Loaded="UserControl_Loaded">

    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.Resources>
            <xctrl:HierarchicalDataTemplate x:Key="ChildTemplate">
                <CheckBox Content="{Binding Path=Name}"  IsChecked="{Binding Path=IsSelected, Mode=TwoWay}"></CheckBox>
            </xctrl:HierarchicalDataTemplate>
            <xctrl:HierarchicalDataTemplate x:Key="ParentTemplate" ItemsSource="{Binding Path=Users, Mode=TwoWay}" ItemTemplate="{StaticResource ChildTemplate}">
                <CheckBox FontStyle="Italic" Content="{Binding Path=Name}" IsChecked="{Binding Path=IsSelected, Mode=TwoWay}"></CheckBox>
            </xctrl:HierarchicalDataTemplate>
        </Grid.Resources>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200" />
            <ColumnDefinition Width="12" />
            <ColumnDefinition Width="1*" />
        </Grid.ColumnDefinitions>
        <data:DataGrid AutoGenerateColumns="False" Name="dataGrid1" Grid.Column="2">
            <data:DataGrid.Columns>
                <data:DataGridCheckBoxColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" />
                <data:DataGridCheckBoxColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" />
                <data:DataGridCheckBoxColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" />
                <data:DataGridCheckBoxColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" />
                <data:DataGridCheckBoxColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" />
            </data:DataGrid.Columns>
        </data:DataGrid>
        <controls:GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" Grid.Row="0" Name="gridSplitter1" Width="12" Cursor="SizeWE">
            <controls:GridSplitter.Background>
                <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                    <GradientStop Color="#FFBCF1F1" Offset="0" />
                    <GradientStop Color="#FFC8CDCD" Offset="1" />
                    <GradientStop Color="#FFEBFBFB" Offset="0.325" />
                    <GradientStop Color="#FFA3B3B3" Offset="0.797" />
                </LinearGradientBrush>
            </controls:GridSplitter.Background>
        </controls:GridSplitter>
        <Button Content="View" HorizontalAlignment="Left" Margin="7,0,0,5" Name="buttonView" Width="65" Height="23" VerticalAlignment="Bottom" />
        <controls:TreeView Name="treeView" ItemTemplate="{StaticResource ParentTemplate}">

        </controls:TreeView>
    </Grid>
</UserControl>