2
我們有一個Silverlight項目運行良好,但現在我們的客戶希望將其轉換爲HTML5。Xaml(silverlight)轉換爲html5
所以我們用xaml去html5轉換並在c#中使用它。
分析和研究,我迄今所做的:
微軟XAML to HTML Conversion Demo但也有很多的問題與該代碼
看了一個channel9視頻的意大利帥哥解釋Silverlight的一些功能和HTML5
看着Fayde XAML engine written in Javascript that renders on the HTML5 Canvas但似乎沒有用
我們該怎麼辦?
我們沒有任何轉換類,因此最好的方法是逐個比較模板並進行替換。我們可以爲此編寫代碼,或者XSLT可以做到這一點嗎?
我在這裏需要的是一個適當的逐步指導進一步進行。 我的執行計劃應該是什麼?
難道還有比一個
我在這裏展示我的示例代碼XAML比較HTML5/Knockout.js一個其他任何方式:
<UserControl x:Class="Capitation.ElectronicFileGeneration"
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:Mtabcal="clr-namespace:MtabCalender;assembly=MtabCalender"
xmlns:MtabCombobox="clr-namespace:MtabCombobox;assembly=MtabCombobox"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controlsToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="1000" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">
<Grid x:Name="LayoutRootTop">
<StackPanel>
<controlsToolkit:BusyIndicator x:Name="SampleIndicator" Grid.ColumnSpan="3" >
<Grid x:Name="LayoutRoot" Height="600">
<Grid.RowDefinitions>
<RowDefinition Height="1" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Border CornerRadius="15" Margin="0,0,0,410" Grid.Row="1" HorizontalAlignment="Left" Width="994">
<!--<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="White"/>
<GradientStop Color="#BED9F0" Offset="0.633"/>
</LinearGradientBrush>
</Border.Background>-->
</Border>
<TextBlock Height="17" HorizontalAlignment="Left" Margin="81,21,0,0" Name="tbCheckprefix" Text="Check Prefix:" VerticalAlignment="Top" Grid.Row="1" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="167,19,0,0" Name="txtCheckPrefix" VerticalAlignment="Top" Width="46" Grid.Row="1" MaxLength="4" />
<TextBlock Grid.Row="1" Height="17" Name="tbCheckNoF2" HorizontalAlignment="Left" Margin="30,53,0,0" Text="<F2>" VerticalAlignment="Top" />
<TextBlock Height="17" HorizontalAlignment="Left" Margin="74,53,0,0" Name="tbCheckNo" Text="Check Number:" VerticalAlignment="Top" Grid.Row="1" />
<MtabCombobox:Combobox Height="23" HorizontalAlignment="Left" Margin="169,51,0,0" Name="cbCheckNumber" VerticalAlignment="Top" Width="90" DropDownClosed="cbCheckNumber_DropDownClosed" Grid.Row="1">
<ComboBoxItem Content="IN" IsSelected="True" />
<ComboBoxItem Content="NOT IN" />
<ComboBoxItem Content="BETWEEN" />
</MtabCombobox:Combobox>
<TextBox Height="23" HorizontalAlignment="Left" Margin="269,52,0,0" Name="txtFCheckNo" VerticalAlignment="Top" Width="130" Grid.Row="1" MaxLength="8" KeyDown="txtNumeric_KeyDown" />
<Button Content="" Height="23" HorizontalAlignment="Left" Margin="411,52,0,0" Name="btnCheckNo" Grid.Row="1" VerticalAlignment="Top" Width="23" Click="btnCheckNo_Click" >
<ToolTipService.ToolTip>
<ToolTip Content="Search"></ToolTip>
</ToolTipService.ToolTip>
<Button.Template>
<ControlTemplate>
<Image Source="Images/Search-icon.png" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" />
</ControlTemplate>
</Button.Template>
</Button>
<TextBox Height="23" HorizontalAlignment="Left" Margin="446,52,0,0" Name="txtTCheckNo" VerticalAlignment="Top" Width="130" Grid.Row="1" MaxLength="8" KeyDown="txtNumeric_KeyDown" Visibility="Collapsed" />
<Button Content="" Height="23" HorizontalAlignment="Left" Margin="588,52,0,0" Name="btnToCheckNo" Grid.Row="1" VerticalAlignment="Top" Width="23" Click="btnToCheckNo_Click" Visibility="Collapsed">
<ToolTipService.ToolTip>
<ToolTip Content="Search"></ToolTip>
</ToolTipService.ToolTip>
<Button.Template>
<ControlTemplate>
<Image Source="Images/Search-icon.png" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" />
</ControlTemplate>
</Button.Template>
</Button>
<TextBlock Height="17" HorizontalAlignment="Left" Margin="309,87,0,0" Name="tbBank" Text="Bank Name:" VerticalAlignment="Top" Grid.Row="1" />
<MtabCombobox:Combobox Height="23" HorizontalAlignment="Left" Margin="381,83,0,0" Name="cbBankNames" Grid.Row="1" VerticalAlignment="Top" Width="152">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Height="15">
<TextBlock Text="{Binding Code}" />
<TextBlock Text="{Binding Descr}" />
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</MtabCombobox:Combobox>
<Button Content="Generate IIF File" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="60,128,0,0" Name="btnGenerateFile" VerticalAlignment="Top" Width="157" Click="btnGenerateFile_Click" ></Button>
<TextBlock Grid.Row="1" Height="17" HorizontalAlignment="Left" Margin="50,85,0,0" Name="tbPD" VerticalAlignment="Top" FontWeight="Bold" Width="7" TextAlignment="Left" Text="*" Foreground="Red"/>
<TextBlock Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="60,85,0,0" Name="tbPaidDate" Text="Check Run Date:" VerticalAlignment="Top" FontWeight="Bold" />
<!--<sdk:DatePicker Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="168,85,0,0" Name="dpPaidDate" VerticalAlignment="Top" Width="120" KeyDown="dpPaidDate_KeyDown" />-->
<Mtabcal:MtabCalender Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="168,85,0,0" Name="dpPaidDate" VerticalAlignment="Top" Width="120" />
<TextBlock Grid.Row="1" Height="18" HorizontalAlignment="Left" Margin="246,156,0,0" Name="tbMessage" Text="" VerticalAlignment="Top" Width="468" Foreground="#FF0011C5" FontWeight="Bold" />
</Grid>
</controlsToolkit:BusyIndicator>
</StackPanel>
</Grid>
</UserControl>
這不是一件容易的事。一種方法是使用HTML5自定義元素 - 一種HTML5 Web組件技術。在初始遷移中,可以使用XSLT添加'name-'前綴以替換名稱空間,並使用CSS樣式使用CSS樣式替換名稱空間,例如:'display:table' - 請參閱http://www.html5rocks.com/en/tutorials/webcomponents/customelements /更多關於自定義元素 – pgfearo 2014-11-25 08:28:18
@LostCoder所以[編輯]你的問題,並把一個鏈接到「意大利人的channel9視頻...」 – 2014-11-25 10:52:26
最好的方法將類似於Silverlight over WebGL在未來廣泛採用WebGL。否則,我個人不認爲XAML轉換HTML是可行的,因爲XAML更復雜。重寫是目前最好的方法。 – 2014-11-25 11:07:41