Navigating to a different assembly in Silverlight - silverlight

I'm trying to navigate to a page located in a different assembly with no success.
I made an extremely simple Silverlight Navigation Application make my point:
I simply have a Hyperlink with:
NavigateUri="/PageClassLibrary;component/Pages/PageInLibrary.xaml"
In the calling page (MainPage.xaml in MainNavigationApp) I have a Frame with no UriMappings for now.
<Grid x:Name="LayoutRoot">
<navigation:Frame x:Name="ContentFrame"
Style="{StaticResource ContentFrameStyle}"
Navigated="ContentFrame_Navigated"
NavigationFailed="ContentFrame_NavigationFailed">
</navigation:Frame>
<Grid x:Name="NavigationGrid" Style="{StaticResource NavigationGridStyle}">
<StackPanel x:Name="LinksStackPanel" Style="{StaticResource LinksStackPanelStyle}">
<HyperlinkButton x:Name="Link3"
Style="{StaticResource LinkStyle}"
NavigateUri="/PageClassLibrary;component/Pages/PageInLibrary.xaml"
TargetName="ContentFrame"
Content="page in a class library" />
</StackPanel>
</Grid>
</Grid>
But when I run it, I get an error message saying that the page was not found:
Page not found: "/PageClassLibrary;component/Pages/PageInLibrary.xaml"
I even modified MainNavigationApp dependencies, checking depends on PageClassLibrary, but it didn't improve the outcome.
I ran out of ideas. Does anybody have a hint?
Here's thesolution:
https://skydrive.live.com/#cid=B79120F33F3A7A64&id=B79120F33F3A7A64%21105

AAAhhh!, the solution was there in front of my eyes. JUST ADD A REFERENCE TO THE ASSEMBLY. dah!

Related

How to start using Ribbons in WPF

I tried referencing the System.Windows.Controls.Ribbon, the toolbox tab does not show up. If I right-click a tab and click show all, the tab is there, but controls aren't light up. I can add a tab and controls related manually, but after adding the ribbon, things like quickaccesstoolbar and menuitem does not work properly - they are being treated as tabs for some reason. Control groups don't work as well. Simply nothing works as it's supposed to.
I have tried editing XAML directly. It fails in the same manner as using the designer.
The tutorials online are either outdated, for a paid control suite, or simply don't work.
I don't want to use mark-up solutions like http://www.codeproject.com/Articles/364272/Easily-Add-a-Ribbon-into-a-WinForms-Application-Cs , I want something that works in a designer -- Is that too much to ask? If so I'll gladly go back to winforms.
If you work with ribbons, how did you do it? This question seems simple, but after digging for hours I still don't have an answer.
I'm an individual developer, making an open source, free software. As a student I really can't afford 1000$ control suites. I use VS2013 community, I tried using 2015 instead, but all the problems above are the same.
Add this reference:
and this namespace in the XAML file:
and try working with this code example:
<DockPanel>
<Ribbon DockPanel.Dock="Top" Margin="0,-22,0,0">
<Ribbon.ApplicationMenu>
<RibbonApplicationMenu SmallImageSource="Images/list.png">
<RibbonApplicationMenu.AuxiliaryPaneContent>
<RibbonGallery ScrollViewer.VerticalScrollBarVisibility="Auto">
<RibbonGalleryCategory MaxColumnCount="1">
<RibbonGalleryItem
x:Name="GalleryItem1" Content="Application menu content"
MouseOverBackground="Transparent"
MouseOverBorderBrush="Transparent"
CheckedBackground="Transparent"
CheckedBorderBrush="Transparent"
/>
<RibbonGalleryItem>
<Hyperlink x:Name="hl1" Click="hl1_Click">
<Run Text="http://www.bing.com"/>
</Hyperlink>
</RibbonGalleryItem>
</RibbonGalleryCategory>
</RibbonGallery>
</RibbonApplicationMenu.AuxiliaryPaneContent>
<RibbonApplicationMenuItem x:Name="menuItem1" Header="Add"
ImageSource="Images/add.png"/>
<RibbonApplicationMenuItem x:Name="menuItem2" Header="Settings"
ImageSource="Images/system_preferences.png"/>
<RibbonApplicationMenu>
</Ribbon.ApplicationMenu>
<RibbonTab x:Name="rbnTab1" Header="Tab1">
<RibbonGroup x:Name="rbnGr1" Header="General">
<RibbonButton x:Name="btnRibbon1" Label="Save"
LargeImageSource="Images/filesave.png"/>
<RibbonButton x:Name="btnRibbon2" Label="Open"
LargeImageSource="Images/load.png"/>
</RibbonGroup>
<RibbonGroup x:Name="rbnGr2" Header="New group">
<RibbonButton x:Name="btnRibbon3" Label="Font"
LargeImageSource="Images/fonts.png"/>
<RibbonButton x:Name="btnRibbon4" Label="Delete"
LargeImageSource="Images/recycle_bin.png"/>
</RibbonGroup>
</RibbonTab>
<RibbonTab x:Name="rbnTab2" Header="Tab2">
<RibbonGroup x:Name="rbnGr3" Header="Other Group">
<RibbonButton x:Name="btnRibbon5" Label="Play"
LargeImageSource="Images/play.png"/>
<RibbonButton x:Name="btnRibbon6" Label="List"
LargeImageSource="Images/kmenuedit.png"/>
</RibbonGroup>
<RibbonGroup x:Name="rbnGr4" Header="What a group">
<RibbonButton x:Name="btnRibbon7" Label="Sleep"
LargeImageSource="Images/icon_sleep.png"/>
<RibbonButton x:Name="btnRibbon8" Label="Add"
LargeImageSource="Images/add.png"/>
</RibbonGroup>
</RibbonTab>
</Ribbon>
<Grid>
<!-- add your content here-->
</Grid>
</DockPanel>
You can remove the <Ribbon.ApplicationMenu> if you don't like it by addin this property Visibility="Collapsed"
<Ribbon.ApplicationMenu>
<RibbonApplicationMenu Visibility="Collapsed">
</RibbonApplicationMenu>
</Ribbon.ApplicationMenu>
Please take a look at the following. You should be able to have a very basic idea about Ribbon.
http://blogs.msdn.com/b/wpf/archive/2010/08/03/introducing-microsoft-ribbon-for-wpf.aspx
Sample project download
If you want to run the project, you need to change the project's .NET Framework version to 4.0 or above.
Add System.Window.Controls.Ribbon reference to the project
Remove reference like System.Window.Shell and RibbonControlLibrary
The sample should be able to run after you fixed all the namespaces in xmal and the codebehind .cs
http://blogs.msdn.com/b/wpf/archive/2010/08/03/building-a-simple-ribbon-application-in-wpf.aspx
Microsoft Ribbon for WPF (Get the one with Sample for more comprehensive sample)
http://www.microsoft.com/en-us/download/details.aspx?id=11877

Binding in WPF Toolkit on Chart Series

it's my first post here so, sorry for my mistakes in advance:). Here is my problem: I am trying to build a WPF application using the MVVM pattern and I'm not ALWAYS able to load data in my chart. The only time when it works is when I use the PieSeries. In the all other cases I receive an error. What is strange is that in my designer window is amable to see my chart.
Here is my code:
<Border Background="White" BorderThickness="2" BorderBrush="Black" Grid.Column="1">
<!--ContentPresenter Content="{Binding Path=FormHost}">
</ContentPresenter-->
<Grid>
<chart:Chart Name="chart1">
<chart:Chart.Series>
<chart:PieSeries Name="series1" ItemsSource="{Binding ChartItems}"
IndependentValueBinding="{Binding Path=Name}"
DependentValueBinding="{Binding Path=Value}"/>
</chart:Chart.Series>
</chart:Chart>
</Grid>
</Border>
In the viewModel I have among other things:
private ObservableCollection<ChartElement> chartItems;
public MainWindowViewModel()
{
chartItems = new ObservableCollection<ChartElement>();
chartItems.Add(new ChartElement("da011111111111", 3));
chartItems.Add(new ChartElement("adas111111", 490));
chartItems.Add(new ChartElement("adas111111", 341));
chartItems.Add(new ChartElement("adas111111", 413));
chartItems.Add(new ChartElement("adas111111", 143));
}
Image with the error
Thank you in advance.
It seems that the problem is in the WPF Toolkit. The bindings above were correct. The problem was that I had specified the xml:lang in my window other than en-US and because of that the application crashed.
For more details please see here and here

Questions when customize the header of a pivotitem

try to customize the header of each PivotItem, i google first and write code below, this is OK:
<controls:Pivot Title="MyPivot">
<!--Pivot item one-->
<controls:PivotItem>
<controls:PivotItem.Header>
<TextBlock Text="Pivot1" FontSize="40"/>
</controls:PivotItem.Header>
<Grid/>
</controls:PivotItem>
</controls:Pivot>
when I add the second pivot item in this way, an error appears as "Value does not fall within the expected range.",the error starts from [controls:PivotItem] of "pivot item two",
<controls:Pivot Title="MyPivot">
<!--Pivot item one-->
<controls:PivotItem>
<controls:PivotItem.Header>
<TextBlock Text="Pivot1" FontSize="40"/>
</controls:PivotItem.Header>
<Grid/>
</controls:PivotItem>
<!--Pivot item two-->
<controls:PivotItem>
<controls:PivotItem.Header>
<TextBlock Text="Pivot2" FontSize="40"/>
</controls:PivotItem.Header>
<Grid/>
</controls:PivotItem>
</controls:Pivot>
When I build the project, the error just gone away, and the whole app runs like a charm.
But everytime i add a new pivot item in this way, the error shows up.
My questions are:
why does this error happen and how to solve it?
can I ignore this error?
This "error" is thrown just at design-time, and I think you can ignore it. Also, it will go definitively away the first time you build the project (so it means there are no real problems in your project, and also no warnings)!
There are more of this type of errors thrown by the designer.
Ignore it!

Easy way to create a style with only minor changes for a Telerik Control

My project currently has a PieChart with a legend. Due to size restrictions I was asked to make a modification where if you hover over the name in the legend, it would display the full name (in the event that it was partially cut off). This revealed to me the issue that if you want to make a minor functional change in a Telerik control you will have to develop a complete style for it.
I feel like there is no easy answer for this, so I figured I'd ask and see if a smartypants figured something clever out. We use lots of Telerik control so if I could take control of them with something like that without having to completely redo them, it would give me a huge amount of control over my interface's more advanced features.
As a note, we are currently using version 2011.1.315.1040, I tried updating to the newest version today but it seems that they altered a control we use often, so I'd prefer to not have to update unless there is really a benefit since there will be a lot of reworking required.
An example style on telerik's website for what I was attempting to modify can be found here
Here is the piechart we are using as an example.
<telerik:RadChart Name="CoreChart"
VerticalAlignment="Top"
PaletteBrushesUseSolidColors="True"
PaletteBrushesRepeat="True"
BorderBrush="Transparent"
Background="Transparent"
BorderThickness="0">
<telerik:RadChart.PaletteBrushes>
<SolidColorBrush Color="#93d2ff" />
<SolidColorBrush Color="#ce0013" />
</telerik:RadChart.PaletteBrushes>
<telerik:RadChart.SeriesMappings>
<telerik:SeriesMapping>
<telerik:ItemMapping FieldName="Value" DataPointMember="YValue" />
<telerik:ItemMapping FieldName="Title" DataPointMember="LegendLabel" />
<telerik:SeriesMapping.SeriesDefinition>
<telerik:PieSeriesDefinition ShowItemLabels="False"
ShowItemToolTips="True"
ItemToolTipFormat="{Binding ToolTipFormat}">
<telerik:PieSeriesDefinition.InteractivitySettings>
<telerik:InteractivitySettings SelectionMode="Single"
SelectionScope="Item" HoverScope="None"/>
</telerik:PieSeriesDefinition.InteractivitySettings>
</telerik:PieSeriesDefinition>
</telerik:SeriesMapping.SeriesDefinition>
</telerik:SeriesMapping>
</telerik:RadChart.SeriesMappings>
<telerik:RadChart.DefaultView>
<telerik:ChartDefaultView ChartLegendPosition="Right" >
<telerik:ChartDefaultView.ChartArea>
<telerik:ChartArea HorizontalAlignment="Left" LegendName="ChartLegend"
BorderBrush="Transparent" EnableAnimations="True"
Background="Transparent" >
<telerik:ChartArea.AxisX>
<telerik:AxisX AxisLabelsVisibility="Collapsed" />
</telerik:ChartArea.AxisX>
</telerik:ChartArea>
</telerik:ChartDefaultView.ChartArea>
<telerik:ChartDefaultView.ChartLegend >
<telerik:ChartLegend x:Name="ChartLegend" Style="{StaticResource
ChartLegendStyle}" LegendItemMarkerShape="Square" Header=""
BorderThickness="0" Background="Transparent"
BorderBrush="Transparent" Width="150" />
</telerik:ChartDefaultView.ChartLegend>
</telerik:ChartDefaultView>
</telerik:RadChart.DefaultView>
</telerik:RadChart>
The way the control is built, you'll have to have a style with a ControlTemplate for the ChartLegendItem. In the link for Telerik's documentation there is a TextBlock named "PART_TextBlock". Change it to look like this:
<TextBlock x:Name="PART_TextBlock"
Grid.Column="1"
Foreground="{TemplateBinding Foreground}"
Margin="{TemplateBinding Margin}"
Padding="{TemplateBinding Padding}"
Text="{TemplateBinding Label}"
TextTrimming="CharacterEllipsis"
ToolTipService.ToolTip="{Binding Text, RelativeSource={RelativeSource Self}}" />
In the instance of ChartLegend
<telerik:ChartLegend x:Name="ChartLegend"
.....
LegendItemStyle="{StaticResource MyLegendItemStyle}" />
This will save you the need for a style of a Legend.
Another tip, to get all default styles of Telerik's controls, go to c:\Program Files (x86)\Telerik\RadControls for Silverlight Q1 2011\Themes - there's a solution there that has all the styles of all the themes.

Silverlight: "The name already exists in the tree"

this is a problem that regularly arises when I write Silverlight XAML. In this case, I've made a usercontrol VerticalTabStop (code attached) that has a ToolTip attached. I instanciate a couple of my usercontrols, and then I get the debugging window and the following error:
Line:52
Error: Unhandled Error in Silverlight 2 Application
Code: 2028
Category: ParserError
Message: The name already exists in the tree: AltLabel.
File:
Line: 0
Position: 0
I get an awful lot of these messages as I hover my mouse over the buttons. Any suggestions to what I'm doing wrong here?
Cheers
Nik
<UserControl
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"
mc:Ignorable="d"
x:Class="SLEntityPresenterWebPart.VerticalTabStop"
d:DesignWidth="20" d:DesignHeight="27">
<Grid x:Name="LayoutRoot">
<StackPanel>
<Canvas x:Name="TabStopCanvas" Height="27" Width="20">
<ToolTipService.ToolTip>
<TextBlock x:Name="AltLabel" Text="Substitute me"/>
</ToolTipService.ToolTip>
<Image x:Name="IconImg" Canvas.Left="7" Canvas.Top="9" Width="26" Height="26" Source="Contact.png" Canvas.ZIndex="5" Margin="0,-9,0,0" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="0.85" ScaleY="0.85"/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform X="0"/>
</TransformGroup>
</Image.RenderTransform>
</Image>
<Image Source="stop.png" Margin="3,0,0,0"/>
</Canvas>
</StackPanel>
</Grid>
</UserControl>
There is very similar bug even in Silverlight 4.
If you create custom usercontrol, usually:
<UserControl xmlns:MyNameSpace="clr-namespace:MyNameSpace" x:Class="MyNameSpace.MyClass"
x:Name="userControl" ... />
Then, if you add 2 controls without names to the xaml code (with preview):
<MyNameSpace:MyClass ... />
<MyNameSpace:MyClass ... />
There will be exception "The name already exists in the tree: userControl". It occurs because Silverlight can't find the name (unnamed [MyClass]) and looks to the UserControl where it finds "userControl" twice.
One of the solution is to give some names to the controls:
<MyNameSpace:MyClass x:Name = "MyControl1" ... />
Or initialize this control from code:
MyClass control = new MyClass();
SomeGrid.Children.Add(control);
This is a bug in Silvelight. The way to work around it is to remove the Name attribute on the TextBlock in the Tooltip.
I presume that you have the name there for a reason, and that not being able to refer to this element from code is going to be a problem for you. As a work around for that, try replacing the tooltip xaml with this:
<ToolTipService.ToolTip>
<ToolTip x:Name="AltLabel" Content="Substitute me" />
</ToolTipService.ToolTip>
Now you can get to the text by doing AltLabel.Content.
If this does not solve your problem, please let me know.
I was struggling with the same message yesterday...
ParserError - The name already exists in the tree: blah
In my case the problem was that somehow a reference was added... to itself. (The DLL of the project in the projects own bin/debug folder). Removing this reference sorted out the problem.
Seems that this error message is too vague.
Try to remove any name like ' x:Name="TabStopCanvas" ' in stack panel, it worked for me.

Resources