I'm trying to increase the length of time that a tooltip displays in a silverlight application. I downloaded Silverlight.Controls.ToolTip from codeplex and I add it as a reference. Here is my code in my xaml:
xmlns:Controls="clr-namespace:Silverlight.Controls.ToolTips;assembly=Silverlight.Controls.ToolTips"
<Button Content="button content">
<Controls:ToolTipService.ToolTip>
<Controls:ToolTip DisplayTime="00:00:10" InitialDelay="00:00:03">
<TextBlock Text="tooltip"></TextBlock>
</Controls:ToolTip>
</Controls:ToolTipService.ToolTip>
</Button>
The code compiles. However, while running the code I get an error "XamlParseException occurred The attachable property 'ToolTip' was not found in 'ToolTipService.' Any ideas on what is causing this error? Thanks!
I had the same problem, here is how I solved it.
1) Go to: http://tooltipservice.codeplex.com/SourceControl/BrowseLatest
2) Download the Source Code
3) Copy "ToolTip.cs", "ToolTipService.cs" and ToolTipTimer.cs from
"branches\2.2.0\Silverlight.Controls.ToolTips\" into your own project somewhere.
4) Now point the xmlns to assembly on your own project where you have copied the source file into.
So basically, just use the source file instead of the dll and it will work. This has worked for me, hope it works for you.
Good Luck.
If you are referencing the ToolTip DLL from another DLL, try also adding a reference to it into you main project.
You have downloaded this DLL from web and have not unblocked it yet.
Right Click on the DLL, go to properties and unblock it.
Related
I got little problem with my image path for ribonn aplicaton menu item.
I got this piece of code:
<ribbon:RibbonApplicationMenuItem x:Name="MenuItemLogout" Header="Odhásit"
ImageSource="/Resources/logoutSmall.png"
Command="{Binding RelogUserCommand}"/>
The thing i want is: the right path of image. Because in this case, Visual Studio cant find that path. This are two different project. The one where i using this ribbon is called Z05.WPF.WeighingSystem in folder 01_LoadingPlace/ViewAnnouncedVehicles - in this folder i have particular xaml and view model.
And i have another project called Z05.DesktopApplication where i have folder called Resources and there i have all of my images. I also tried to use this path:
pack://application:,,,/Resources/
But its also doesnt work.
Any tips? Thanks! :)
I tried to set up a Icon in XAML from the Resources.resx but it cant find the resources.
Code:
....
xmlns:resx="clr-namespace:Admin_Overwatch.Properties"
Title="MainWindow" Height="400" Width="600" Icon="{x:Static
resx:Resources.TitelLogomRand1}">
Error:
"The name "Resources" doesen´t exist in the namespace...."
The courious thing is that in the autoformat it finds every icon in the Resources file. I have Rebuild it without any success and tried a new Resource folder also with no success.
Why doesn´t it find the Folder(s) ?
Edit:
I tried this tutorial also without any success, I got the same error, it can´t find the resources....
http://social.technet.microsoft.com/wiki/contents/articles/22420.binding-to-resources-resx-files-in-xaml.aspx
The Answer was to use the Assembly in addition to the normal clr:
xmlns:resx="clr-namespace:Admin_Overwatch.Properties;assembly=Admin-Overwatch"
xmlns:local="clr-namespace:Admin_Overwatch;assembly=Admin-Overwatch"
The Assembly name can be found by
Right Click on the Project name under Properties --> Application.
But the important part is that it is not possible to load the pictures from the resx in wpf that goes only in win forms.
see here:
How to use Resources.resx to link images
I had simmilar problem. Added a placeholder image to use as default ImageSource in XAML on startup. I created it trough Project+Right-Click->Properties>Resources>Add Resource>New Image etc.
Then got to Resource folder in the project, selected the image and down bellow in properties I just selected Build Action to Resource. And now it works!
I get that error if i try to run my "application". In fact that's an empty window with background.
<Window x:Class="NWN_Tsuki.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="831" Width="875">
<Window.Background>
<ImageBrush Stretch="None" ImageSource="pack://siteoforigin:,,,/Resources/Book.png" />
</Window.Background>
<Grid/>
</Window>
That's all my app. And i get error. If i set absolute path to image - all working fine.
I tried to google, i searched same topics here and tried to do what worked for others - there are no progress. Just one window. Just one background image in resourses added through wizard.
Visual Studio 2013, Windows 7 Ultimate x64
I haven't tried adding an image thru a wizard, what I do is create a "Resources" folder in my project. Then I add the image in said folder. Set the property of the image to Copy Always or Copy If New. Then do:
<ImageBrush Stretch="None" ImageSource="../Resources/Book.png" />
If anything, Book.png is just not getting copied.
EDIT: IMPORTANT Also make sure to change the Book.png's Build Action to Resource
First of all, I think you can just write ImageSource="Resources/Book.png" and it will work.
Second, if you want with "pack://", you suppose to write it ImageSource="pack://application:,,,/Resources/Book.png"
Yet another way - ImageSource="ProjectName;component/Resources/Book.png" where ProjectName is the name of the project where you keep you picture.
You can even concatenate all this if you need ImageSource="pack://application:,,,/ProjectName;component/Resources/Book.png"
I have experienced this. It turned out, the .png was corrupted. When I navigated to the folder in File Explorer, I saw the following
I think the mkelem is something to do with our source control, so maybe it was that which corrupted it, regardless, this is why some people may get this error message.
My application has certain errors, in its error box during design time, to do with it's resource dictionary. For example, in my Main Window a resource dictionary is called as follows;
<Window.Resources>
<ResourceDictionary Source="Resources.xaml"/>
</Window.Resources>
I get a blueline on the middle line saying "An error has occurred while finding the resource dictionary "Resources.xaml". Yet, the Resources.xaml is in the root folder of the project, and so is the MainWindow.
I am aware that there are similar questions like this out there, however the answers;
"Make sure Resources.xaml is set to build action: page"
"Make sure you are correctly referencing Resources.xaml"
were not helpful to me.
I have an additional problem in that, within the resource dictionary, I have errors telling me;
the name ProductDatabaseViewModel does not exist in the namespace "clr-namespace:gate2software.ViewModels"
and similarly;
the name ProductDatabaseView does not exist in the namespace "clr-namespace:gate2software.Views"
in the following xaml;
<DataTemplate DataType="{x:Type vm:ProductDatabaseViewModel}">
<vw:ProductDatabaseView />
</DataTemplate>
In reality both of these are available exactly where they are stated to be.
Any suggestions for either of my two problems would be greatly appreciated.
make sure your path is correct? or try like dis path:
<ResourceDictionary Source=ms-appx:///CustomControls/Resources.xaml>
Have you tried to close the designer process (sometimes this works)?
Task Manager > Details > XDesProc.exe > end process. You will be able to reload it by clicking refresh in any VS view, but first rebuild all.
And by the way, Resources.xaml is for sure a ResourceDictionary type and not Page ? This kind of errors are shown also when you try to add a page as resource, not a ResourceDictionary.
I just ran into this same issue. My projects were targeted for a x64 build. I changed them to Any CPU See below and was able to see my view model data at design time.
In my first few hours with Silverlight 3, as an avid WPF user, I am greatly disappointed at the many things it doesn't support. This seems like an odd issue to me and it's so generic that I cannot find anything online about it.
I have the following XAML:
<controls:TabControl x:Name="workspacesTabControl" Grid.Row="1"
Background="AntiqueWhite" ItemsSource="{Binding Workspaces, ElementName=_root}"/>
However, I cannot see the workspacesTabControl in code-behind. I thought maybe IntelliSense is just being mean and tried to go ahead and compile it anyway, but got an error:
Error 1 The name 'workspacesTabControl' does not exist in the current context
How do I access controls in code-behind?
EDIT: I realized I've pasted the wrong error - I have two controls inside the UserControl called workspacesTabControl and menuStrip. I cannot get to either one of them by their name in the code-behind.
Just in case, here is the XAML for the menuStrip:
<controls:TreeView Grid.ColumnSpan="2" Height="100" x:Name="menuStrip"
ItemContainerStyle="{StaticResource MenuStripStyle}"
ItemsSource="{Binding Menu, ElementName=_root}"/>
EDIT AGAIN:
I'm not sure if this is helpful, but I've taken a look at the InitializeComponent() code and here's what I saw:
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Windows.Application.LoadComponent(this, new System.Uri("/SapphireApplication;component/SapphireMain.xaml", System.UriKind.Relative));
}
It seems that it simply loads the XAML when it runs (not before or during compilation) so the menuStrip and workspacesTabControl names don't actually get registered anywhere (as they usually are in WPF/win Forms). Could that attribute be a problem? And where do I get rid of this requirement for all the future UserControls I make?
Check the properties in VS for the xaml file itself... make sure the Build Action is set to Page.
As ridiculous as it may sound, I have resorted to using FindName() method to access named items in code-behind:
this.FindName("workspacesTabControl") as TabControl
I realize that this is a ridiculous way but I am forced to use this for now. Please let me know if someone else has encountered this problem and have come up with a better solution!
When you first create a control, Visual Studio does not pick it up with intellisense. However, after you try to build the project, it should become availble. You can also just type the name in without intellisense and then build it. Haven't verified this, but I heard this was on the list of things to fix in SL4.
That being said, if you name a control inside of a datatemplate, that control is not directly accessible in code-behind. This is the same for WPF, though.
You should be able to see it in the codebehind, that part works the same as WPF, maybe if you fix the problem with the menuStrip, then visual studio will be able to build the xaml paty of the page and ull be able to access the tabcontrol
I've seen the same problem in my Silverlight development. Specific to my problem my named controls were nested inside other controls (i.e. a datagrid) and I was unable to access them in my code behind. Any named controls at the same nesting level or above the previously mentioned datagrid worked fine but anything inside it was lost into the abyss.
As already mentioned, it should just appear in Intellisense, however the fact that you're getting an error related to something else, i.e. "menuStrip" is probably interfering with Intellisense. Resolve that error and you'l probably find that you can access the "workspacesTabControl" control.
Are you possibly using some sample code or something where they've named a control "menuStrip" and you've renamed it?
Good luck
Check that you don't have any controls using the same class name as a namespace name. For example:
namespace Solution.ProjectName.workspacesTabControl
{
public class workspacesTabControl
{
...
}
}
This will also give you this error.
Good luck,
Mark