C# 如何在asp.net网站项目中使用xaml

C# 如何在asp.net网站项目中使用xaml,c#,asp.net,wpf,xaml,C#,Asp.net,Wpf,Xaml,我可以在ASP.NET项目中使用XAML文件吗。例如,当我打开localhost/tryconnect.aspx时,我想查看XAML文件。可能吗 MainWindows.xamlcode: <Window x:Class="TFSMove.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft

我可以在ASP.NET项目中使用XAML文件吗。例如,当我打开
localhost/tryconnect.aspx
时,我想查看XAML文件。可能吗

MainWindows.xaml
code:

<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>
 namespace TFSMove
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public static DependencyProperty MoveEnabledProperty = DependencyProperty.Register("MoveEnabled", typeof(bool), typeof(MainWindow), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
        public bool? MoveEnabled
        {
            get
            {
                return GetValue(MoveEnabledProperty) as bool?;
            }
            set { SetValue(MoveEnabledProperty, value); }
        }

        public static DependencyProperty TFS_ServerProperty = DependencyProperty.Register("TFS_Server", typeof(Uri), typeof(MainWindow), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
        private Uri TFS_Server
        {
            get
            {
                return
                    GetValue(TFS_ServerProperty) as Uri;
            }
            set { SetValue(TFS_ServerProperty, value); }
        }

        public static DependencyProperty TFS_WorkItemsProperty = DependencyProperty.Register("TFS_WorkItems", typeof(WorkItemCollection), typeof(MainWindow), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
        private WorkItemCollection TFS_WorkItems
        {
            get
            {
                return GetValue(TFS_WorkItemsProperty) as WorkItemCollection;
            }
            set { SetValue(TFS_WorkItemsProperty, value); }
        }

        private DispatcherTimer _tfs_server_text_changed_timer;

        public MainWindow()
        {
            InitializeComponent();
            _BtnQuery.IsEnabled = false;
        }

        private void _TFSServer_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (_tfs_server_text_changed_timer == null)
            {
                _tfs_server_text_changed_timer = new DispatcherTimer();
                _tfs_server_text_changed_timer.Tag = sender;
                _tfs_server_text_changed_timer.Tick += _TFSServer_PostTextChanged;
            }

            _tfs_server_text_changed_timer.Interval = TimeSpan.FromMilliseconds(750);
            _tfs_server_text_changed_timer.Start();

            e.Handled = true;
        }

        private void _TFSServer_PostTextChanged(object sender, EventArgs e)
        {
            (sender as DispatcherTimer).Stop();
            TextBox tb = (sender as DispatcherTimer).Tag as TextBox;
            if (sender.Equals(_tfs_server_text_changed_timer))
            {
                _tfs_server_text_changed_timer.Tag = null;
                _tfs_server_text_changed_timer = null;
            }

            TfsTeamProjectCollection TPC = null;
            Uri tfs_server_ = null;

            if (Uri.TryCreate(tb.Text, UriKind.Absolute, out tfs_server_))
            {
                TFS_Server = tfs_server_;
                try
                {
                    TPC = new TfsTeamProjectCollection(TFS_Server);
                }

                catch (Exception ex)
                {
                    Paragraph p = new Paragraph(new Run(ex.InnerException == null ? ex.Message : ex.InnerException.Message));
                    p.Foreground = Brushes.Red;
                    _WorkItemDisplay.Document.Blocks.Add(p);
                    _BtnQuery.IsEnabled = false;
                    return;
                }
            }

            else
                TFS_Server = null;

            if (TPC == null)
            {
                _WorkItemDisplay.AppendText(".");
                _BtnQuery.IsEnabled = false;
                return;
            }

            Cursor saved_cursor = this.Cursor;
            this.Cursor = Cursors.Wait;

            //!?this._To_Projects.SelectedValuePath = "Id";
            this._To_Projects.DisplayMemberPath = "Name";
            this._To_Projects.ItemsSource = TPC.GetService<WorkItemStore>().Projects;

            _WorkItemDisplay.Document.Blocks.Add(new Paragraph(new Run("Connected to: " + tb.Text)));
            _BtnQuery.IsEnabled = true;

            this.Cursor = saved_cursor;
        }

        private void _To_Projects_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (_To_Projects.SelectedItem == null)
            {
                _To_Areas.ItemsSource = null;
                _To_Iterations.ItemsSource = null;
            }

            else
            {
                Cursor saved_cursor = this.Cursor;
                this.Cursor = Cursors.Wait;

                //!?_To_Areas.SelectedValuePath = "Id";
                _To_Areas.DisplayMemberPath = "Name";
                _To_Areas.ItemsSource = (_To_Projects.SelectedItem as Project).AreaRootNodes;

                //!?_To_Iterations.SelectedValuePath = "Id";
                _To_Iterations.DisplayMemberPath = "Name";
                _To_Iterations.ItemsSource = (_To_Projects.SelectedItem as Project).IterationRootNodes;

                this.Cursor = saved_cursor;
            }
        }

        private void _BtnQueryClick(object sender, RoutedEventArgs e)
        {
            StringBuilder wiquery = new StringBuilder(this._WorkItemQuery.Text);
            int work_item_number = 0;
            if (int.TryParse(this._WorkItemQuery.Text, out work_item_number))
            {
                wiquery.Clear();
                wiquery.Append("SELECT * FROM WorkItems WHERE [System.Id] = '");
                wiquery.Append(work_item_number.ToString());
                wiquery.Append("'");
            }

            Cursor saved_cursor = this.Cursor;
            this.Cursor = Cursors.Wait;
            _WorkItemDisplay.Document.Blocks.Clear();
            try
            {
                TfsTeamProjectCollection TPC = new TfsTeamProjectCollection(TFS_Server);
                TPC.EnsureAuthenticated();
                TFS_WorkItems = TPC.GetService<WorkItemStore>().Query(wiquery.ToString());

                switch (TFS_WorkItems.Count)
                {
                    case 0:
                        _WorkItemDisplay.Document.Blocks.Add(new Paragraph(new Run("No items were returned from search.")));
                        _From_Project.Text = string.Empty;
                        break;

                    case 1:
                        {
                            Table t = new Table();
                            GridLengthConverter lc = new GridLengthConverter();
                            t.Columns.Add(new TableColumn() { Width = (GridLength)lc.ConvertFromString("*") });
                            t.Columns.Add(new TableColumn() { Width = (GridLength)lc.ConvertFromString("3*") });

                            TableRowGroup rg = new TableRowGroup();
                            TableRow r = new TableRow();
                            r.Cells.Add(new TableCell(new Paragraph(new Run(TFS_WorkItems[0].Fields["ID"].Name))));
                            r.Cells.Add(new TableCell(new Paragraph(new Run(TFS_WorkItems[0].Fields["ID"].Value.ToString()))));
                            rg.Rows.Add(r);
                            r = new TableRow();
                            r.Cells.Add(new TableCell(new Paragraph(new Run(TFS_WorkItems[0].Fields["Title"].Name))));
                            r.Cells.Add(new TableCell(new Paragraph(new Run(TFS_WorkItems[0].Fields["Title"].Value.ToString()))));
                            rg.Rows.Add(r);
                            r = new TableRow();
                            r.Cells.Add(new TableCell(new Paragraph(new Run(TFS_WorkItems[0].Fields["Area Path"].Name))));
                            r.Cells.Add(new TableCell(new Paragraph(new Run(TFS_WorkItems[0].Fields["Area Path"].Value.ToString()))));
                            rg.Rows.Add(r);
                            r = new TableRow();
                            r.Cells.Add(new TableCell(new Paragraph(new Run(TFS_WorkItems[0].Fields["Iteration Path"].Name))));
                            r.Cells.Add(new TableCell(new Paragraph(new Run(TFS_WorkItems[0].Fields["Iteration Path"].Value.ToString()))));
                            rg.Rows.Add(r);

                            _From_Project.Text = TFS_WorkItems[0].Fields["Team Project"].Value.ToString();

                            foreach (Field f in TFS_WorkItems[0].Fields)
                            {
                                if (f.Value != null)
                                {
                                    string value = f.Value.ToString();
                                    if (!string.IsNullOrWhiteSpace(value))
                                    {
                                        r = new TableRow();

                                        r.Cells.Add(new TableCell(new Paragraph(new Run(f.Name))));
                                        r.Cells.Add(new TableCell(new Paragraph(new Run(value))));

                                        rg.Rows.Add(r);
                                    }
                                }
                            }
                            t.RowGroups.Add(rg);

                            _WorkItemDisplay.Document.Blocks.Add(t);
                        }
                        break;

                    default:
                        {
                            Table t = new Table();
                            GridLengthConverter lc = new GridLengthConverter();
                            t.Columns.Add(new TableColumn() { Width = (GridLength)lc.ConvertFromString("*") });
                            t.Columns.Add(new TableColumn() { Width = (GridLength)lc.ConvertFromString("7*") });

                            TableRowGroup rg = new TableRowGroup();
                            TableRow r = new TableRow();

                            r.Cells.Add(new TableCell(new Paragraph(new Run(TFS_WorkItems[0].Fields["ID"].Name)) { FontWeight = FontWeights.Bold }));
                            r.Cells.Add(new TableCell(new Paragraph(new Run(TFS_WorkItems[0].Fields["Title"].Name)) { FontWeight = FontWeights.Bold }));

                            rg.Rows.Add(r);

                            _From_Project.Text = TFS_WorkItems[0].Fields["Team Project"].Value.ToString();

                            foreach (WorkItem wi in TFS_WorkItems)
                            {
                                r = new TableRow();
                                r.Cells.Add(new TableCell(new Paragraph(new Run(wi.Fields["ID"].Value.ToString()))));
                                r.Cells.Add(new TableCell(new Paragraph(new Run(wi.Fields["Title"].Value.ToString()))));
                                rg.Rows.Add(r);
                            }

                            t.RowGroups.Add(rg);

                            _WorkItemDisplay.Document.Blocks.Add(t);
                        }
                        break;
                }
            }

            catch (Exception ex)
            {
                _WorkItemDisplay.Document.Blocks.Add(new Paragraph(new Run(ex.InnerException == null ? ex.Message : ex.InnerException.Message)) { Foreground = Brushes.Red });
                _From_Project.Text = string.Empty;
            }

            this.Cursor = saved_cursor;
        }

        private void _BtnMoveClick(object sender, RoutedEventArgs e)
        {
            Cursor saved_cursor = this.Cursor;
            this.Cursor = Cursors.Wait;
            _WorkItemDisplay.Document.Blocks.Clear();
            _From_Project.Text = string.Empty;
            SqlConnection conn = null;
            try
            {
                conn = new SqlConnection(_SQLConnection.Text);
                conn.Open();

                if (TFS_WorkItems.Count == 0)
                {
                    _WorkItemDisplay.Document.Blocks.Add(new Paragraph(new Run("Nothing to move.")) { Foreground = Brushes.Red });
                }

                else
                {
                    TfsTeamProjectCollection TPC = new TfsTeamProjectCollection(TFS_Server);
                    TPC.EnsureAuthenticated();

                    WorkItemStore WIS = TPC.GetService<WorkItemStore>();
                    StringBuilder sql_command_are = new StringBuilder();
                    StringBuilder sql_command_latest = new StringBuilder();
                    StringBuilder sql_command_were = new StringBuilder();

                    foreach (WorkItem wi in TFS_WorkItems)
                    {
                        sql_command_are.Clear();
                        sql_command_latest.Clear();
                        sql_command_were.Clear();

                        sql_command_are.Append("UPDATE [WorkItemsAre] SET AreaID='");
                        sql_command_latest.Append("UPDATE [WorkItemsLatest] SET AreaID='");
                        sql_command_were.Append("UPDATE [WorkItemsWere] SET AreaID='");

                        sql_command_are.Append((_To_Areas.SelectedItem as Node).Id.ToString());
                        sql_command_latest.Append((_To_Areas.SelectedItem as Node).Id.ToString());
                        sql_command_were.Append((_To_Areas.SelectedItem as Node).Id.ToString());

                        sql_command_are.Append("', IterationID='");
                        sql_command_latest.Append("', IterationID='");
                        sql_command_were.Append("', IterationID='");

                        sql_command_are.Append((_To_Iterations.SelectedItem as Node).Id.ToString());
                        sql_command_latest.Append((_To_Iterations.SelectedItem as Node).Id.ToString());
                        sql_command_were.Append((_To_Iterations.SelectedItem as Node).Id.ToString());

                        sql_command_are.Append("' WHERE ID='");
                        sql_command_latest.Append("' WHERE ID='");
                        sql_command_were.Append("' WHERE ID='");

                        sql_command_are.Append(wi.Id.ToString());
                        sql_command_latest.Append(wi.Id.ToString());
                        sql_command_were.Append(wi.Id.ToString());

                        sql_command_are.Append("'");
                        sql_command_latest.Append("'");
                        sql_command_were.Append("'");

                        new SqlCommand(sql_command_are.ToString(), conn).ExecuteNonQuery();
                        new SqlCommand(sql_command_latest.ToString(), conn).ExecuteNonQuery();
                        new SqlCommand(sql_command_were.ToString(), conn).ExecuteNonQuery();

                        _WorkItemDisplay.Document.Blocks.Add(new Paragraph(new Run("Moved " + wi.Id.ToString() + " to " + (_To_Projects.SelectedItem as Project).Name)));
                    }
                }
            }

            catch (Exception ex)
            {
                _WorkItemDisplay.Document.Blocks.Add(new Paragraph(new Run(ex.InnerException == null ? ex.Message : ex.InnerException.Message)) { Foreground = Brushes.Red });
                _From_Project.Text = string.Empty;
            }

            finally
            {
                if (conn != null)
                    conn.Close();
            }

            this.Cursor = saved_cursor;
        }

        private void UpdateMoveEnabled(object sender, SelectionChangedEventArgs e)
        {
            BindingOperations.GetMultiBindingExpression(_BtnMove, Button.IsEnabledProperty).UpdateTarget();
        }

        private void _BtnSQLTestClick(object sender, RoutedEventArgs e)
        {
            Cursor saved_cursor = this.Cursor;
            this.Cursor = Cursors.Wait;
            _WorkItemDisplay.Document.Blocks.Clear();

            try
            {
                SqlConnection conn = new SqlConnection(_SQLConnection.Text);
                conn.Open();
                SqlCommand sql_cmd = new SqlCommand("SELECT COUNT(*) FROM [WorkItemsAre]", conn);
                int wi_count = (int)sql_cmd.ExecuteScalar();
                conn.Close();

                _WorkItemDisplay.Document.Blocks.Add(new Paragraph(new Run("Success! " + wi_count.ToString() + " work items counted.")));
            }

            catch (Exception ex)
            {
                _WorkItemDisplay.Document.Blocks.Add(new Paragraph(new Run(ex.InnerException == null ? ex.Message : ex.InnerException.Message)) { Foreground = Brushes.Red });
            }

            this.Cursor = saved_cursor;
        }
    }

    public class AndConverter : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parm, System.Globalization.CultureInfo culture)
        {
            switch (targetType.Name)
            {
                case "Boolean":
                case "Nullable`1":
                    {
                        for (int i = 0; i < values.Count(); i++)
                        {
                            if (values[i] == null)
                                return false;

                            switch (values[i].GetType().Name)
                            {
                                case "Boolean":
                                case "Nullable`1":
                                    if (values[i] as bool? ?? false)
                                        continue;
                                    return false;

                                case "String":
                                case "string":
                                    if (string.IsNullOrWhiteSpace(values[i] as string))
                                        return false;

                                    else if ("0".CompareTo(values[i] as string) == 0 || "false".CompareTo((values[i] as string).ToLower()) == 0)
                                        return false;
                                    break;

                                case "Node":
                                    if ((values[i] as Node).Id > 0)
                                        continue;
                                    return false;

                                default:
                                    throw new NotImplementedException("Cannot process input type " + values[i].GetType().Name);
                            }
                        }

                        return true;
                    }

                default:
                    throw new NotImplementedException("Cannot process output type " + targetType.Name);
            }
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parm, System.Globalization.CultureInfo culture)
        {
            object[] ret = new object[targetTypes.Count()];
            for (int i = 0; i < targetTypes.Count(); i++)
                ret[i] = System.Convert.ChangeType(value, targetTypes[i]);

            return ret;
        }
    }
}

您可以在Silverlight中使用XAML

有关silverlight的stackoverflow的问题:


结构等同于WPF,但它们之间的某些特性不同:

< P>如果您想运行本地WPF应用程序,则需要考虑创建像格林所说的XBAP应用程序。请注意,现代浏览器中对XBAP应用程序的支持很少,而且可能会受到限制

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


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

Silverlight的扩展支持将于2021年12月10日结束,这使得Silverlight似乎应该出现在ahwile中,对吗?错。为了在web上运行Silverlight应用程序,您需要一个支持它的浏览器。Chrome在9月后将不支持Silverlight。如果用户想要运行Silverlight插件,Firefox会让他们跃跃欲试。在Windows10下,用户必须运行IE11,Edge不会运行Silverlight应用程序


web上的XAML已死。

您考虑过XBAP吗?感谢您的帮助,我添加了design和XAML.c。如何在.aspx屏幕中查看我的设计?请看这个问题