Reputation: 2924
I needed to use datepicker control in my WPF application but I couldn't find this control in Toolbox. Then I installed WPFToolKit and added namespace in xaml file code but still it shows following error:
Error 1 The tag 'DatePicker' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'. Line 23 Position 18. F:\Muhammad Anees\codereason_reports_v0.5_alpha\Samples\SimpleReport\EmployeeManager.xaml 23 18 Employee_Manager
Here is my xaml file code:
<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 Control is after second Radiobutton Control in above code. Please tell me how to overcome this problem. thanks
Upvotes: 0
Views: 2335
Reputation: 4122
IF this is the wpf toolkit from nuget then you call it like:
<toolkit:DatePicker Name="blah blah" Margin="0" ect.. > </toolkit:DatePicker>
You may also have to try and clean and build the solution cause I actually got this error before to using the toolkit, but it worked after I rebuilt the solution.
Upvotes: 1
Reputation: 223257
I think you are using WPF Toolkit, you need to use toolkit as you have specified that in the start for WPF toolkit Assembly
<toolkit:DatePicker Height="25" HorizontalAlignment="Left" Margin="42,26,0,0" Name="datePicker1" VerticalAlignment="Top" Width="115" />
Upvotes: 2