ToolTip inside a page within frame - c#

I need to use the ToolTip on a label inside a xaml
<Page x:Class="xxx.xxx"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="464" d:DesignWidth="628"
Title="ManagementDetails" Loaded="Page_Loaded">
<Grid>
<Label Margin="0,360,376,91" >
<ToolTipService.ToolTip>
<ToolTip Content="Turtle" />
</ToolTipService.ToolTip>
</Label>
</Grid>
</Page>
this xaml file is used to be a child inside a frame contained in another xaml file
<Window x:Class="xxx.xxxxxx"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="ViewProject" Height="626" Width="810" >
<Grid Height="600" Width="800">
<Frame Margin="172,136,0,0" Name="frame1" />
</Grid>
</Window>
i embedded the page xaml file inside the frame using
MyClass myClass= new MyClass();
frame1.Navigate(myClass);
if i moved the label with the ToolTip from the page xaml file to the window xaml file the ToolTip work but when use it inside the page xaml file it doesn't work.
what is missing here to make it work inside the page xaml file

Why are you doing it this way?!?
Just do something like:
<Label Name="Some_Label" ToolTip="Turtle"> Fun with labels ...</Label>
Done. Should work inside another or by itself.

Using the ToolTip Control:
The ToolTipService class must be used along with the ToolTip control in order to display a tooltip to our control. For the example I will use an image control, but the following can be applied to each of the controls. Here is the code:
<Image Source="GiantSeaTurtle.jpg" Width="400" Height="300">
<ToolTipService.ToolTip>
<ToolTip Content="Turtle"></ToolTip>
</ToolTipService.ToolTip>
</Image>

Thanks guys for all your answers it seems that is was my fault and feel ashamed, i had duplicate xaml files for the same page and i was editing one and viewing another one. Sorry for this inconvenience and thanks again for your help.

Related

How to add multiple content control on same window [duplicate]

Problem:
XAML file:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" x:Class="WpfApp1.MainWindow"
mc:Ignorable="d"
Title="Test" Height="398.775" Width="782" BorderBrush="Black" Margin="0" IsTabStop="True">
<Window.TaskbarItemInfo>
<TaskbarItemInfo/>
</Window.TaskbarItemInfo>
<TextBox HorizontalAlignment="Left" Height="23" Margin="268,290,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
</Window>
A Window is a ContentControl. These have a Content property to display a single item. If you want to display multiple items, use one of the following built-in layout panels and drag them onto your window. Then you can add multiple controls to them.
Grid
StackPanel
WrapPanel
DockPanel
UniformGrid
Canvas
Because you're on the window who only accepts 1 element, you need first add a content controller .
It can be:
Grid
Canvas
Dock Panel
StackPanel
WrapPannel
Scroll viewer
Add <grid> </grid> in Window tag then you can add your controls in it.

Why can't I put more than one control on a window?

Problem:
XAML file:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" x:Class="WpfApp1.MainWindow"
mc:Ignorable="d"
Title="Test" Height="398.775" Width="782" BorderBrush="Black" Margin="0" IsTabStop="True">
<Window.TaskbarItemInfo>
<TaskbarItemInfo/>
</Window.TaskbarItemInfo>
<TextBox HorizontalAlignment="Left" Height="23" Margin="268,290,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
</Window>
A Window is a ContentControl. These have a Content property to display a single item. If you want to display multiple items, use one of the following built-in layout panels and drag them onto your window. Then you can add multiple controls to them.
Grid
StackPanel
WrapPanel
DockPanel
UniformGrid
Canvas
Because you're on the window who only accepts 1 element, you need first add a content controller .
It can be:
Grid
Canvas
Dock Panel
StackPanel
WrapPannel
Scroll viewer
Add <grid> </grid> in Window tag then you can add your controls in it.

Custom xmlns namespaces not working

I am trying to follow these instructions for separating tab content into separate files. Here is my file structure
I am trying to load file 2's content with file 1 so that they work together. Here is file 2:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<UserControl x:Key="Tab1Control">
<DataTemplate DataType="TabItem">
<TextBlock Text="Test text"></TextBlock>
</DataTemplate>
</UserControl>
</ResourceDictionary>
And the relevant portion of file 1:
<Window x:Class="MnMCharacterCreator.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tabs="TabContent/TabAttributesContent">
...
<!--Creates a tabbing system, with a grid defined by each ItemsControl-->
<TabControl Name="WindowTabs">
<TabItem Name="WindowTab1" Header="Attributes">
<!--This is where the UserControl from file 2 should be loaded-->
After visiting these two related questions (with tens of others) and asking on C# chat, I'm left thinking that this is unusual:
Intellisense shows nothing for <tabs: and even if I manually type an existing name or something, an error message is given, meaning that it is not a designer issue. Here is the full solution in VS2012.
To be specific, the question I am trying to ask is how can I use content from another xaml file? If xmlns isn't possible, what is?
You may want to create a user control for tab item as ,
<UserControl x:Class="WPFSample.TabItem1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300">
<Grid>
<TextBlock Height="100" Width="100" Text="Hi from tab item 1"/>
</Grid>
Then for using this add the namespace in the MainWindow as :
<Window x:Class="WPFSample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
xmlns:local="clr-namespace:WPFSample">
<Grid>
<TabControl>
<TabItem Header="XYZ">
<local:TabItem1/>
</TabItem>
</TabControl>
</Grid>
You are ready to use .
Hope you have changed the usercontrol xaml.cs from XYZ : Window to XYZ : UserControl and build the solution once .

Is there a way to display WPF Extended Toolkit's control in VS Designer?

I'm used to create my forms with the designer, and modifying the XAML manually only when needed.
Even though the extended toolkit is a fantastic library, it still lacks integration with Visual Studio's designer. Can, by any mean, the toolkit's controls be displayed in the designer (not the toolbox), like standard controls? And if not, is there an explanation?
For now, the toolkit's controls are just blank and unselectable with simple clicks.
NOTE: It seems that the issue happens with container components (like BusyIndicator and Wizard/WizardPage) only.
EDIT: Here's some of my XAML. With this, I can see the wizard's first page, but no obvious way to see the others. If I put my Wizard in a BusyIndicator, can't see a thing at all.
<Window x:Class="MyProgram.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MyProgram"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
Title="My Program" Height="477" Width="688" MinWidth="688" MinHeight="478">
<xctk:Wizard x:Name="wizard" FinishButtonClosesWindow="True" Next="wizard_Next">
<xctk:WizardPage Name="Intro_Page" Title="ABC" Description="abc" NextPage="{Binding ElementName=Second_Page}" Enter="disallowNext">
<xctk:WizardPage.Content>
<Grid>
<Label Content="abc" HorizontalAlignment="Center" Margin="0,54,0,87" Name="intro_lbl" VerticalAlignment="Center" Grid.Column="1" Padding="5" HorizontalContentAlignment="Center" Height="28" IsEnabled="False" />
</Grid>
</xctk:WizardPage.Content>
</xctk:WizardPage>
<xctk:WizardPage Name="Second_Page" Title="DFG" Description="dfg" NextPage="{Binding ElementName=Last_Page}">
<xctk:WizardPage.Content>
<Grid Name="grid">
<TextBox Grid.Column="1" Height="23" HorizontalAlignment="Stretch" Name="txt_second" VerticalAlignment="Center" />
</Grid>
</xctk:WizardPage.Content>
</xctk:WizardPage>
<xctk:WizardPage Name="Last_Page" PageType="Interior"
Title="Last Page"
Description="This is the last page in the process"
CanFinish="True" />
</xctk:Wizard>
</Window>
I know this answer comes late, but yesterday I was stumbling myself over this problem and maybe it is useful for others who land here.
I solved it by creating an own control derived from WizardPage.
Just Create a new UserControl, include the Xceed.Wpf.Toolkit namespace and change the Type from UserControl to xctk:WizardPage in the xaml file as well as in the code-behind file.
<xctk:WizardPage x:Class="WizardTest.MyWizardPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:xctk="clr-namespace:Xceed.Wpf.Toolkit;assembly=Xceed.Wpf.Toolkit"
xmlns:local="clr-namespace:WizardTest"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<TextBlock>Hello World!</TextBlock>
</Grid>
</xctk:WizardPage>
Now you can create your UI using the VisualStudio Designer.
To place your page in the wizard, simply put an object of you derived page into its items:
<xctk:Wizard>
<local:MyWizardPage Title="My Wizard Page"/>
</xctk:Wizard>
You can use Bindungs in your costum page out of the box because DataContext of the MyWizardPage object is set automatically to the wizards DataContext (which inherits from the Window DataContext if not explicitly given)

Simple XAML to XAML page navigation

I am trying to simply navigate from one .xaml page to another. I realize that the navigation template is built for this but I do not want the mainpage header / content below feel that it brings. Using a blank Silverlight application (C#) I want to move from Page1.xaml to Page2.xaml using a hyperlink button.
On Page1.xaml I have a hyperlink button like this:
<HyperlinkButton Content="Preview Report" Height="24" HorizontalAlignment="Stretch" Margin="98,296,377,21" Name="hyperlinkButton1" NavigateUri="/Page2.xaml" />
this doesn't seem to work. Please help
You will need a navigation frame in your MainPage in order to support this. Start with blank Silverlight Application.
Modify MainPage.xaml to look like:-
<UserControl x:Class="StackoverflowSpikes.NavPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<navigation:Frame Source="/Page1.xaml" />
</Grid>
</UserControl>
Add two or more Navigation Page's to your project. Now you can add HyperLinkButton elements to them.

Categories