I am hoping this problem is just me being unfamiliar with WPF.
I am able to use the XCeed toolkit in code with no problems:
DateTimePicker dtp = new DateTimePicker();
dtp.HorizontalAlignment = HorizontalAlignment.Left;
dtp.VerticalAlignment = VerticalAlignment.Top;
dtp.Width = 200;
dtp.Height = 24;
dtp.Margin = new Thickness(50, 10, 0, 0);
dtp.FontStyle = FontStyles.Normal;
InBoundGrid.Children.Add(dtp);
This works fine in my form.
But I cannot figure out how do get it working in the designer:
I've added:
xmlns:wpfx="http://schemas.xceed.com/wpf/xaml/toolkit"
to the Window definition.
It shows fine in "intellisense"
So when I start typing wpfx:... the DateTimePicker contol shows in the intellisense menu.
However:
<wpfx:DateTimePicker
HorizontalAlignment="Left"
VerticalAlignment="Top"
Width="200"
Height="24"
Margin="50,10,0,0"
FontWeight="Normal"
/>
comes back with the error:
"The name "DateTimePicker" does not exist in the namespace http://schemas.xceed.com/wpf/xaml/toolkit"
All the other Xceed controls show the same error in xaml designer.
Also, please note I do not want to try the Nuget installer.
(I tried but got the same error anyway)
I would like to keep my code base as small as possible.
Thanks in advance.
Took me awhile, but I finally found a solution:
1) Go To Build|Configuration Manager
2) Under "Active solution platform" select
3) Change to x64
I had the setting set for AnyCPU. I think it is the default for VS.
The designer came back as soon as I set it to x64.
Hopefully this may help anyone else using the Xceed Toolkit in designer.
Your code seems to be fine I don't see anything wrong with it. As long as you are sure that url is the correct one to be including.
For me sometimes Visual Studio is a little funny with the XAML. After adding the resource try to rebuild the solution, or clean it then hit build. This seems to refresh the XAML resources. If this doesn't work try restarting Visual Studio.
Related
I user reportviewer for my winform app!!!
now when i select reportviewer control from toolbox and add that to page controler, any thing not shown on form designer , but bottom of page the name of reportviewer will be seen!!!
i really confused for this problem !!!
this problem appeared when i make backup from my project !!! and before that i did't have any problem with report viewer!
(i set location and size of reportviewer manually but ...)
this.reportViewer1.Location = new System.Drawing.Point(0, 0);
this.reportViewer1.Name = "ReportViewer";
this.reportViewer1.Size = new System.Drawing.Size(396, 246);
this.reportViewer1.TabIndex = 0;
this.reportViewer1.Visible = true;
I found a workaround
this line Manual added
this.Controls.Add(this.reportViewer1);
on method
InitializeComponent
Why when
Drag-drop control on the Windows Forms
Not added automatic
P.s
Sorry for my english
I had the same problem as you and I solved it by updating the dll Windows.ReportViewer.Winform (version 10.0) to (version 11.0) with Nuget.
For those that didn't have the ReportViewer control in the Toolbox so they followed the instructions and added the control manually -- if you don't see the ReportViewer control after dragging the (now available) ReportViewer control, then right click on References in your project structure, then browse to the exact same location from where you took the ....WinForm.dll or WebForm.dll and this time choose ...Designer.dll.
Rebuild your project and try dragging again. This time the control should be visible on the form.
install version 11.0.3452.
It's working for me. enter image description here.
How I solved the same issue. Deleted the reference Windows.ReportViewer.Winform and Microsoft.ReportViewer.Common and dragged report viewer control on the form and added this line this.Controls.Add(this.reportViewer1); in private void InitializeComponent()
Install the nuget package:-
Microsoft.ReportingServices.ReportViewerControl.Winforms
It will solve the issue
Hi I am having a very strange problem. I have a form with multiple tooltips that appear when the mouse is over a specific control. So far I was developing the form on a Windows 7 machine and everything were going fine. Tonight I tested my executable on my other Windows 7 machine (same version and service pack) but none of the tooltips are working.
Does anybody have an idea what might be the problem? Bellow I am giving the code for one such Tooltip
ToolTip UrlNameInputBallonTip = new ToolTip();
private void CheckForUrl()
{
UrlNameInputBallonTip.IsBalloon = true;
if (IsValidHttpUri(UrlNameInput.Text) == false && IsValidHttpsUri(UrlNameInput.Text) == false)
{
UrlNameInputBallonTip.SetToolTip(UrlNameInput, "This is not a valid url!\r\nex. \"http://domain\"");
UrlNameInputBallonTip.Show("This is not a valid url!\r\nex. \"http://domain\"", UrlNameInput, UrlNameInput.Width / 2, UrlNameInput.Height, 5000);
}
else
{
UrlNameInputBallonTip.Hide(this);
}
}
Hi I was able to find the cause of the problem and I am reporting this for future reference. On the suspected machine the option to display balloon tips (arrow pointing to the control) was disabled. I am not sure why, perhaps some other app disable it at some point, but after enabling it through registry ti works fine now. Thanks for the help!
I would like to hide several textboxes, a label and a button as soon as a button is clicked... however, for some reason, my code doesn't seem to cause this effect. Nothing appears to happen. I'm using WPF.
Here is my code:
private void doSomething_Click(object sender, RoutedEventArgs e)
{
Name.Visibility = Visibility.Hidden;
}
This code doesn't seem to work.. any ideas?
I believe Visibility.Collapsed is what you need and not Visibility.Hidden.
EDIT: Did you try follow up this code with UpdateLayout() method of parent element/component?
Your code seems to work fine, the "Signing in..." label appears after everything else disappear. I suggest you to just copy all your code from the .xaml.cs file and the .xaml file into a new project, but make sure you don't copy the first line"<Window x:Class="..." because it could generate an error if the class name isn't the same in the new project.
For the xaml code I suggest you not think the same as you design windows forms applications. WPF has the layout system, which re-orientates or re-sizes its elements when re-sizing the window. So you should not specify exact numbers in the margin property as if they where coordinates. Create a grid, create rows or columns for each element and then just set the horizontal or vertical alignment or margins. Think different than the old windows forms way.
I've run your code... and it's working great for me. I've not changed anything (except the variable names) so I guess it's a bug from VS.
As said nikolamm94 try to add this.UpdateLayout(); at the end of connect_Click it might help. I tried and it is still working fine. Or maybe create a new VS projet, it already worked for me a few times.
Sorry my answer is not the most helpful, I wanted to put a comment instead but I don't have enough reputation :/
Please refer: https://msdn.microsoft.com/en-us/library/ms748821(v=vs.85).aspx
Set to Visible: tb1.Visibility = System.Windows.Visibility.Visible;
Set to Hide: tb1.Visibility = System.Windows.Visibility.Hidden;
You can hide a textbox by going to properties->appearance->visibility, then setting it to "hidden"
I'm trying to set the current WPF Application ResourceDictionary programatically. (I have a WindForms project, so no "App.xaml" to do that for me).
Note: If anyone knows how to bind the equivalent of an Application.Resources to a ElementHost and all of its child controls hierarchy, this is the ultimate objective here.
I added to my code:
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("/Middlewerks;component/Resources.xaml", UriKind.RelativeOrAbsolute) });
Now it works perfectly in the application, the styling is fine (i.e.: Grids' backgrounds are red. It's just a test style).
But if I open this form in the designer, Visual Studio goes crazy. The whole window uses my style!
Here's a screenshot: http://localhostr.com/files/8368cc/Failure.jpg
The cool part is that I found how to edit the Visual Studio 2010 ugly blue skin. The sad part is that won't make my customers happy when they develop with my control.
Feel free to try it and tell me how I should implement my resources without screwing everything up.
XAML Code: (shown in screenshot)
EDIT: Here is my temporary, very hackish solution so I can keep on developing. It really is a pain that "Application.Current" works on Visual Studio.
if (Application.Current.MainWindow == null || !Application.Current.MainWindow.Title.EndsWith(" - Microsoft Visual C# 2010 Express"))
{
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("/Middlewerks;component/Resources.xaml", UriKind.RelativeOrAbsolute) });
}
When I worked on a WinForms project that used WPF areas, I just used MergedDictionaries to bring in the resources I needed, whenever I needed them.
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="DefaultResourceDictionary.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
Can you get away with that? You can still put a code behind on the dictionary if you need to do more programmatically.
You can use this at any level on any element. That is, it doesn't have to be a Window as shown here.
I plan to add functionalities to TextBox with the following:
public class TextBoxExt : TextBox
{
protected override void OnKeyPress(KeyPressEventArgs e)
{
base.OnKeyPress(e);
}
}
The question is how can we use this TextBoxExt? Is there anyway to get this class onto the ToolBox so that we can just drag and drop it onto the form? If not, what is the best way to use the TextBoxExt?
Build you project with TextBoxExt, make sure it compiles ok.
With the form that you want TextBoxExt on, open the toolbox, right click and select "choose items"
Browse to you .exe or dll that you compiled in 1)
make sure that TextBoxExt has a tick next to it, press ok
TextBoxExt should appear in the toolbox, drag it onto your form
(There is another way of doing this, opening the designer file and renaming the instances of TextBox to TextBoxExt but manual editing of designer files can be considered hazardous by some)
I know this is super old question, but maybe still useful for someone else that has same problem like me - as it's still on the top Google :)
You might interest to use ToolboxItemAttribute (http://msdn.microsoft.com/en-us/library/system.componentmodel.toolboxitemattribute(v=vs.110).aspx).
I did this at my end to resolve the problem.
[ToolboxItem(true)]
public class PanelTitle : LabelControl {
// Whatever code to override LabelControl here...
}
Rebuild the solution and the extended control should be shown in the toolbox.
Any custom control in your project should show up in the Toolbox automatically. I have found that sometimes the controls won't show until you close a re-open Visual Studio. I assume the issue has something to do with caching of the contents of the Toolbox.
You need to add a constructor to your derived class.
public class TextBoxExt : TextBox
{
public TextBoxExt()
{
}
protected override void OnKeyPress(KeyPressEventArgs e)
{
base.OnKeyPress(e);
}
}
Your control should appear in the toolbox for your solution automatically. To have it appear for other projects, you have to do Choose Toolbox items, as others have said.
If you want to provide special design-time functionality, then you will also need to provide some additional designer related attributes and probably your own class derived from ControlDesigner.
I fell into this trap just a couple of hours ago.
I've got a .NET 2.0 Windows Application project with some custom UserControls; it worked fine.
So I decided to order my files in subfolders, to make my project a little bit cleaner.
After that, Visual Studio 2010 designer stopped loading my forms, and ToolBox won't show my controls anymore.
I freaked out, moving back source files in project root, resetting ToolBox, but nothing seemed to work.
After that, I remembered I used ReSharper "Remove Unused References", so I tried to put back unused reference, in particular System.Data: problem solved! :O
I can't say you why, but this worked for me.
Hope my experience can help someone else. :)
Bye,
Nando
I created an empty constructor for my custom implementation of UltraGridBagLayoutPanel. Although david.healed is right it isn't necessary, it is quite useful to put a breakpoint in to check that when the form initialises it is using your class to implement your custom control.
It would have been a lot easier to edit the designer file, but I tried it and changed both the field type for the control and also changed the assignment of the field to a new instance of my custom control.
private Infragistics.Win.Misc.UltraGridBagLayoutPanel ultraGridBagLayoutPanel1;
this.ultraGridBagLayoutPanel1 = new Infragistics.Win.Misc.UltraGridBagLayoutPanel();
to
private Athia.Reports.ultraGridBagLayoutPanel1 ultraGridBagLayoutPanel1;
this.ultraGridBagLayoutPanel1 = new Athia.Reports.ultraGridBagLayoutPanel1();
Doing this destroys Visual Studio every time, and to fix it requires using a text editor to put it back again. Therefore unless anyone can describe what is wrong with my implementation of this approach, perhaps calling the class the same as the control name isn't a great idea, I think the only safe and reliable way to achieve this is as Calanus describes in steps 1 to 5 or as an small deviation from that as Rob Windsor rightly points out restarting VS will bring the control into the Toolbox automatically. Unfortunately for me I then have to change all of the child controls over from the original class to my customised class :-(.
Within the same Solution this should work automatically. However, I have found that if the Target Framework aren't matching the Toolbox does not populate. ( I'm assuming really Reference needs to be of version same or lower than target of Reference. ) ( I did get a warning about non-matching Frameworks )
By making these the same Target Framework, Recompile, Restart VS. the control populated correctly. ( I also added the ToolboxItem(true) Attribute)