0

WPF アプリケーションで datepicker コントロールを使用する必要がありましたが、Toolbox でこのコントロールを見つけることができませんでした。次に、WPFToolKit をインストールし、xaml ファイル コードに名前空間を追加しましたが、それでも次のエラーが表示
されます。 . 行 23 位置 18. F:\Muhammad Anees\codereason_reports_v0.5_alpha\Samples\SimpleReport\EmployeeManager.xaml 23 18 Employee_Manager

これが私のxamlファイルコードです:

<Window x:Class="SimpleReport.EmployeeManager"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:toolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
Title="Employee Manager - Islam Engineering Pvt Ltd." Height="513" Width="865" ResizeMode="CanMinimize">

    <TabControl Height="482" HorizontalAlignment="Left" Margin="0,-2,0,0" Name="tabControl1" VerticalAlignment="Top" Width="832">
        <TabItem Header="Add New Employee" Name="tabItem1">
            <Grid Width="806" Height="440">
                <TextBox Height="23" HorizontalAlignment="Left" Margin="177,14,0,0" Name="txtBarcode" VerticalAlignment="Top" Width="120" Background="#FFE0DECC" KeyUp="txtBarcode_KeyUp" />
                <Label Content="Employee ID:" Height="28" HorizontalAlignment="Left" Margin="19,14,0,0" Name="label1" VerticalAlignment="Top" Width="85" />
                <TextBox Height="23" HorizontalAlignment="Left" Margin="177,49,0,0" Name="emp_name" VerticalAlignment="Top" Width="254" IsEnabled="True" />
                <Label Content="Employee Name:" Height="28" Margin="19,0,676,365" Name="label2" VerticalAlignment="Bottom" />
                <Button Content="Add" Height="23" Name="addbtn" Width="75" Background="#FFD0B8B8" BorderBrush="#FFB19414" Margin="176,136,554,281" Click="addbtn_Click" />
                <Label Height="28" HorizontalAlignment="Left" Margin="177,78,0,0" Name="addmsg" VerticalAlignment="Top" Width="275" Content="Employee added Successfully!" />
            </Grid>
        </TabItem>
        <TabItem Header="Employee Attendance Report" Name="tabItem2">
            <Grid>
                <Label Content="Select Report Type:" Height="28" HorizontalAlignment="Left" Margin="24,26,0,0" Name="label7" VerticalAlignment="Top" Width="122" />
            <Button Background="#FFD0B8B8" BorderBrush="#FFB19414" Content="Generate Report" Height="23" Margin="152,157,557,270" Name="reportBtn" Click="button1_Click" />
            <RadioButton Content="Today's Report" Height="16" HorizontalAlignment="Left" Margin="152,31,0,0" Name="radioButton1" VerticalAlignment="Top" />
            <DatePicker Height="25" HorizontalAlignment="Left" Margin="42,26,0,0" Name="datePicker1" VerticalAlignment="Top" Width="115" />
            <RadioButton Content="Previous Date" Height="16" HorizontalAlignment="Left" Margin="152,62,0,0" Name="radioButton2" VerticalAlignment="Top" />
            <RadioButton Content="Within Range" Height="16" HorizontalAlignment="Left" Margin="152,95,0,0" Name="radioButton3" VerticalAlignment="Top" />
        </Grid>
        </TabItem>
        <TabItem Header="Remove Employee Record" Name="tabItem3">
            <Grid>
                <ComboBox Height="23" HorizontalAlignment="Left" Margin="181,26,0,0" Name="comboBox3" VerticalAlignment="Top" Width="120" SelectionChanged="comboBox3_SelectionChanged" SelectedIndex="0" />
                <Label Content="Select Employee ID:" Height="28" HorizontalAlignment="Left" Margin="29,26,0,0" Name="label5" VerticalAlignment="Top" Width="122" />
                <Button Background="#FFD0B8B8" BorderBrush="#FFB19414" Content="Remove" Height="23" Margin="181,80,566,347" Name="button2" Width="75" />
            </Grid>
        </TabItem>
    </TabControl>

DatePicker コントロールは、上記のコードの 2 番目の Radiobutton コントロールの後にあります。この問題を克服する方法を教えてください。ありがとう

4

2 に答える 2

1

WPF ツールキットを使用していると思います。WPF ツールキット アセンブリの開始時に指定したように、ツールキットを使用する必要があります。

<toolkit:DatePicker Height="25" HorizontalAlignment="Left" Margin="42,26,0,0" Name="datePicker1" VerticalAlignment="Top" Width="115" />
于 2012-04-22T15:58:39.220 に答える
1

これが nuget の wpf ツールキットである場合は、次のように呼び出します。

 <toolkit:DatePicker Name="blah blah" Margin="0" ect.. > </toolkit:DatePicker>

ツールキットを使用する前に実際にこのエラーが発生したため、ソリューションをクリーンアップしてビルドする必要がある場合もありますが、ソリューションを再構築した後には機能しました。

于 2012-04-22T16:00:20.490 に答える