我怎样才能在asp.net网站项目中使用xaml

时间:2015-08-17 14:22:39

标签: c# asp.net wpf xaml

我可以在ASP.NET项目中使用XAML文件吗?例如,当我打开SELECT * from <table> where <column> = $$robocopy'w (ithout)backup.pcap$$; 时,我想看到XAML文件。有可能吗?

localhost/tryconnect.aspx代码:

MainWindows.xaml

<Window x:Class="TFSMove.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="http://schemas.microsoft.com/netfx/2009/xaml/presentation" x:Name="_MainWindow" Width="500" Height="450" Title="Move TFS Work Items" > <Window.Resources> <local:AndConverter x:Key="AndConverter"/> </Window.Resources> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="350" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition /> </Grid.ColumnDefinitions> <Grid Grid.Row="0" Grid.ColumnSpan="3" > <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <Label Grid.Row="0" Grid.Column="0" HorizontalAlignment="Right" Margin="5" Content="TFS Server:"/> <TextBox x:Name="_TFSServer" Grid.Row="0" Grid.Column="1" Margin="5" TextChanged="_TFSServer_TextChanged" > <TextBox.Resources> <VisualBrush x:Key="hint" TileMode="None" Opacity="0.4" Stretch="None" AlignmentX="Left"> <VisualBrush.Transform> <TranslateTransform X="5" Y="0" /> </VisualBrush.Transform> <VisualBrush.Visual> <Grid> <TextBox BorderThickness="0" FontStyle="Italic" Foreground="Black" Text="&lt;Enter the URL to the TFS project server.&gt;"/> </Grid> </VisualBrush.Visual> </VisualBrush> </TextBox.Resources> <TextBox.Style> <Style TargetType="TextBox"> <Style.Triggers> <Trigger Property="Text" Value="{x:Null}"> <Setter Property="Background" Value="{StaticResource hint}" /> </Trigger> <Trigger Property="Text" Value=""> <Setter Property="Background" Value="{StaticResource hint}" /> </Trigger> </Style.Triggers> </Style> </TextBox.Style> </TextBox> <Button x:Name="_BtnMove" Grid.Row="0" Grid.Column="2" Margin="5" Click="_BtnMoveClick" Content="¡Move!"> <Button.IsEnabled> <MultiBinding Converter="{StaticResource AndConverter}" Mode="OneWay"> <Binding ElementName="_From_Project" Path="Text" Mode="OneWay"/> <Binding ElementName="_To_Areas" Path="SelectedItem" Mode="OneWay"/> <Binding ElementName="_To_Iterations" Path="SelectedItem" Mode="OneWay"/> </MultiBinding> </Button.IsEnabled> </Button> <Label Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right" Margin="5" >SQL Connection:</Label> <TextBox x:Name="_SQLConnection" Grid.Row="1" Grid.Column="1" MinWidth="100" Margin="5" > <TextBox.Resources> <VisualBrush x:Key="hint" TileMode="None" Opacity="0.4" Stretch="None" AlignmentX="Left"> <VisualBrush.Transform> <TranslateTransform X="5" Y="0" /> </VisualBrush.Transform> <VisualBrush.Visual> <Grid> <TextBox BorderThickness="0" FontStyle="Italic" Foreground="Black" Text="&lt;Enter the SQL Connection String to the TFL Server SQL database.&gt;"/> </Grid> </VisualBrush.Visual> </VisualBrush> </TextBox.Resources> <TextBox.Style> <Style TargetType="TextBox"> <Style.Triggers> <Trigger Property="Text" Value="{x:Null}"> <Setter Property="Background" Value="{StaticResource hint}" /> </Trigger> <Trigger Property="Text" Value=""> <Setter Property="Background" Value="{StaticResource hint}" /> </Trigger> </Style.Triggers> </Style> </TextBox.Style> </TextBox> <Button x:Name="_BtnSQL" Grid.Row="1" Grid.Column="2" Margin="5" Click="_BtnSQLTestClick" IsEnabled="{Binding ElementName=_SQLConnection, Path=Text.Length}" >¡Test!</Button> <Label Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right" Margin="5" >Query:</Label> <TextBox x:Name="_WorkItemQuery" Grid.Row="2" Grid.Column="1" MinWidth="100" Margin="5" > <TextBox.Resources> <VisualBrush x:Key="hint" TileMode="None" Opacity="0.4" Stretch="None" AlignmentX="Left"> <VisualBrush.Transform> <TranslateTransform X="5" Y="0" /> </VisualBrush.Transform> <VisualBrush.Visual> <Grid> <TextBox BorderThickness="0" FontStyle="Italic" Foreground="Black" Text="&lt;Enter the WorkItem Number or Query for moving.&gt;"/> </Grid> </VisualBrush.Visual> </VisualBrush> </TextBox.Resources> <TextBox.Style> <Style TargetType="TextBox"> <Style.Triggers> <Trigger Property="Text" Value="{x:Null}"> <Setter Property="Background" Value="{StaticResource hint}" /> </Trigger> <Trigger Property="Text" Value=""> <Setter Property="Background" Value="{StaticResource hint}" /> </Trigger> </Style.Triggers> </Style> </TextBox.Style> </TextBox> <Button x:Name="_BtnQuery" Grid.Row="2" Grid.Column="2" Margin="5" Click="_BtnQueryClick" IsEnabled="{Binding ElementName=_WorkItemQuery, Path=Text.Length}">Search</Button> </Grid> <GridSplitter Grid.Column="1" Grid.Row="2" ShowsPreview="True" VerticalAlignment="Stretch" Width="6" HorizontalAlignment="Center" Margin="0,0,0,0" /> <RichTextBox x:Name="_WorkItemDisplay" Grid.Row="2" Grid.Column="0" Margin="5" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"> <RichTextBox.Resources> <Style TargetType="{x:Type Paragraph}"> <Setter Property="Margin" Value="0" /> </Style> </RichTextBox.Resources> </RichTextBox> <Grid Grid.Row="1" Grid.Column="2"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition/> </Grid.RowDefinitions> <GroupBox Grid.Row="0" FontSize="16" Margin="5,0,5,5"> <GroupBox.Header>From</GroupBox.Header> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition /> </Grid.RowDefinitions> <TextBlock x:Name="_From_Project" Grid.Row="0" Margin="5,0,5,0" TextWrapping="WrapWithOverflow" /> </Grid> </GroupBox> <Rectangle Grid.Row="1" Margin="1" SnapsToDevicePixels="True" Height="1" Width="Auto" Fill="Black" /> <GroupBox Grid.Row="2" FontSize="16" Margin="5,0,5,5"> <GroupBox.Header>To</GroupBox.Header> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition /> </Grid.RowDefinitions> <Label Grid.Row="0" Margin="5,0,5,0" FontSize="{Binding ElementName=_BtnMove, Path=FontSize}" Content="Project:"/> <ComboBox x:Name="_To_Projects" Grid.Row="1" Margin="5,0,5,5" FontSize="{Binding ElementName=_BtnMove, Path=FontSize}" SelectionChanged="_To_Projects_SelectionChanged" /> <Label Grid.Row="2" Margin="5,0,5,0" FontSize="{Binding ElementName=_BtnMove, Path=FontSize}" Content="Area:"/> <ComboBox x:Name="_To_Areas" Grid.Row="3" Margin="5,0,5,5" FontSize="{Binding ElementName=_BtnMove, Path=FontSize}" SelectionChanged="UpdateMoveEnabled" /> <Label Grid.Row="4" Margin="5,0,5,0" FontSize="{Binding ElementName=_BtnMove, Path=FontSize}" Content="Iteration:"/> <ComboBox x:Name="_To_Iterations" Grid.Row="5" Margin="5,0,5,5" FontSize="{Binding ElementName=_BtnMove, Path=FontSize}" SelectionChanged="UpdateMoveEnabled"/> </Grid> </GroupBox> </Grid> </Grid> </Window> 代码:

MainWindow.xaml.cs

3 个答案:

答案 0 :(得分:1)

您可以在Silverlight中使用XAML

有关silverlight的stackoverflow的问题:https://stackoverflow.com/search?q=siverlight

结构等于WPF,但它们之间的某些功能不同

答案 1 :(得分:0)

如果你想运行本机WPF应用程序,你需要考虑创建像Glen这样的XBAP应用程序。请注意,现代浏览器中的XBAP应用程序支持在今天很少见,并且可能受到限制。

如果要在ASP.NET网站中使用XAML控件/文件,则需要先编写Silverlight应用程序,然后将控件添加到您的网站。请注意,某些浏览器甚至停止支持Silverlight应用程序

Reference materials

答案 2 :(得分:0)

在Web应用程序中使用XAML的最佳方法是使用Silverlight。此时使用Silverlight对任何项目都不是一个好主意。

对Silverlight的扩展支持将于10/12/2021结束,这使得看起来像Silverlight应该是为了ahwile,对吗?错误。要在Web上运行Silverlight应用程序,您需要一个支持它的浏览器。 Chrome在9月之后不会支持Silverlight。如果想要运行Silverlight插件,Firefox正在让用户跳槽。在Windows 10下,用户必须运行IE11,Edge不会运行Silverlight应用程序。

网络上的XAML已经死了。