|
i have one multi series line chart. i m displaying datetime on x-axis. i have rotate my datetime values by 270 degree angle. now problem is that x-axis values showing on two places on chart. one at bottom and aother at top of chart area. i need only one x-axis valur as we do in any standard chart.
my code is:
<UserControl xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" x:Class="TestExcelChart.MainPage"
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:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
xmlns:layout="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<UserControl.Resources>
</UserControl.Resources>
<Canvas x:Name="LayoutRoot" Background="White" Width="600" >
<sdk:TabControl x:Name="pnlxlChart" TabStripPlacement="Top" VerticalAlignment="Top"
Height="700" Width="600" HorizontalAlignment="Left" Canvas.Left="24"
>
<sdk:TabItem Height="20" Header=" Excel Data">
<StackPanel>
<sdk:DataGrid x:Name="excelData" AutoGenerateColumns="False" />
</StackPanel>
</sdk:TabItem>
<sdk:TabItem Height="20" Header="Column Chart">
</sdk:TabItem>
<sdk:TabItem Height="20" Header="Line Chart">
<charting:Chart x:Name="LineChart" Grid.Row="2" Title="Line Chart" Height="500">
<charting:Chart.Series>
<charting:LineSeries DataContext="users"
IndependentValuePath="Name" DependentValuePath="Score" >
<charting:LineSeries.IndependentAxis>
<charting:CategoryAxis Orientation="X">
<charting:CategoryAxis.AxisLabelStyle>
<Style TargetType="charting:AxisLabel">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="charting:AxisLabel">
<layout:LayoutTransformer>
<layout:LayoutTransformer.LayoutTransform>
<RotateTransform Angle="270"/>
</layout:LayoutTransformer.LayoutTransform>
<TextBlock Text="{TemplateBinding FormattedContent}" RenderTransformOrigin="0.5,0.5"/>
</layout:LayoutTransformer>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</charting:CategoryAxis.AxisLabelStyle>
</charting:CategoryAxis>
</charting:LineSeries.IndependentAxis>
</charting:LineSeries>
<charting:LineSeries DataContext="users"
IndependentValuePath="Name" DependentValuePath="Score2" >
<charting:LineSeries.IndependentAxis>
<charting:CategoryAxis Orientation="X">
<charting:CategoryAxis.AxisLabelStyle>
<Style TargetType="charting:AxisLabel">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="charting:AxisLabel">
<layout:LayoutTransformer>
<layout:LayoutTransformer.LayoutTransform>
<RotateTransform Angle="270"/>
</layout:LayoutTransformer.LayoutTransform>
<TextBlock Text="{TemplateBinding FormattedContent}" RenderTransformOrigin="0.5,0.5" />
</layout:LayoutTransformer>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</charting:CategoryAxis.AxisLabelStyle>
</charting:CategoryAxis>
</charting:LineSeries.IndependentAxis>
</charting:LineSeries>
</charting:Chart.Series>
</charting:Chart>
</sdk:TabItem>
</sdk:TabControl>
</Canvas>
</UserControl>
|
|
|
|
|
Hi,
How to open or navigate to a XAML page from a button click in the .aspx page in the .web project.
Thankyou
YPKI
|
|
|
|
|
Redirect .aspx to the page that's hosting the Xaml!
C# has already designed away most of the tedium of C++.
|
|
|
|
|
Hi all -
I added a Silverlight application to my solution - an asp.net website.
It added an html and aspx file in the root, also a ClientBin dir.
If I link to the html or aspx file, the SL content displays - in a page by itself.
So, I tried to add the SL object to an asp:wizard page. I copied the div from the aspx and put it on the page. I also added the javascript error code and the link to the js file.
The SL content wont show in the wizard. I set the source to "..\\ClientBin\..." and the js to "..\\silverlight.js" because the wizard is at the same level as the ClientBin content. changing the size and background of the object does work, and not adding ..\\ causes the javascript onerror code to execute.
Can anyone let me know what else I need to do? Any help would be appreciated.
Thanks!
J
|
|
|
|
|
Have you tried to change the width and height to pixels instead of %?
This post may be of help : http://forums.silverlight.net/p/232055/569580.aspx[^]
------------------------------------------------------------
"The only true wisdom is in knowing you know nothing." --Socrates
|
|
|
|
|
Hi Xenon - thanks for the response.
Yes I tried setting the height and width to pixels and I do get a box that will bring up the silverlight menu when you right click inside it, but thats all.
Basically, if the pages that load the sl object are in the root of my project - like the test aspx and html pages added by default when the sl project is created - it works fine.
If I try and load the sl object from a page in a folder (at the same level as ClientBin) It doesn't work. even if I copy the same html or aspx pages directly from the root.
I have to change a couple things -
<param name="source" value="ClientBin/Silverlight Object.xap"/>
becomes
<param name="source" value="..\\ClientBin/Silverlight Object.xap"/> and
<script type="text/javascript" src="Silverlight.js"></script>
becomes
<script type="text/javascript" src="..\\Silverlight.js"></script>
(I don't think the .js is being used, so I don't think I need to do this. If I don't change the ClientBin to ..\\ClientBin, I will get a load error thrown.
Do I need to set mime types or something? I read something about them only being set for the root of the project directory. I am using VS2010.
Thanks!
J
here's the page source I get -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
Silverlight Object
</title>
<style type="text/css">
.style1
{
width: 100%;
}
html, body {
height: 100%;
overflow: auto;
}
body {
padding: 0;
margin: 0;
}
#silverlightControlHost {
height: 500px;
text-align:center;
}
</style>
<script type="text/javascript" src="..\\Silverlight.js"></script>
<script type="text/javascript">
function onSilverlightError(sender, args) {
var appSource = "";
if (sender != null && sender != 0) {
appSource = sender.getHost().Source;
}
var errorType = args.ErrorType;
var iErrorCode = args.ErrorCode;
if (errorType == "ImageError" || errorType == "MediaError") {
return;
}
var errMsg = "Unhandled Error in Silverlight Application " + appSource + "\n";
errMsg += "Code: " + iErrorCode + " \n";
errMsg += "Category: " + errorType + " \n";
errMsg += "Message: " + args.ErrorMessage + " \n";
if (errorType == "ParserError") {
errMsg += "File: " + args.xamlFile + " \n";
errMsg += "Line: " + args.lineNumber + " \n";
errMsg += "Position: " + args.charPosition + " \n";
}
else if (errorType == "RuntimeError") {
if (args.lineNumber != 0) {
errMsg += "Line: " + args.lineNumber + " \n";
errMsg += "Position: " + args.charPosition + " \n";
}
errMsg += "MethodName: " + args.methodName + " \n";
}
alert(errMsg);
throw new Error(errMsg);
}
</script>
</head>
<body>
<form method="post" action="Page1.aspx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJODExMDE5NzY5ZGR3pKj0yol3dSXA8CS0ZrlCCYJQXLMakDaYymKobcWj8w==" />
</div>
<span id="Label1">Not Silverlight</span>
<div id="silverlightControlHost">
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="400px" height="400px">
<param name="source" value="..\\ClientBin/Silverlight Object.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="blue" />
<param name="minRuntimeVersion" value="4.0.50826.0" />
<param name="autoUpgrade" value="true" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0" style="text-decoration:none">
<img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
</a>
</object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>
</form>
</body>
</html>
|
|
|
|
|
- my own stupid mistake.
<param name="source" value="..\\ClientBin/Silverlight Object.xap"/>
should have been -
<param name="source" value="../ClientBin/Silverlight Object.xap"/>
it is working great now
|
|
|
|
|
Hey,
Ive wrote a WPF application and now i wont to give a user the this feature:
1.User will write some DLL that will be based on WPF GUI.
2.When the user will ask my application to load his DLL my APP will load it and present it on the main window then user will work with it.
3.After he will finish to work with it he will ask to unload it.
Question:
1.How it possible to write DLL with WPF GUI?
2.I dont know which DLL's will be so i need to load them dynamicly,how can i do this(maybe user have to implement some inteface in his DLL)?
|
|
|
|
|
To be able to unload dll's you need to load them into a separate ApplicationDomain and when you are done with the dll you need to unload the AppDomain.
//daniel
|
|
|
|
|
I've added xmlns="" to all my XmlDataProvider (after Googling for sometime[^]), but from Visual Studio output Window still getting the very annoying error message - "XmlDataProvider has inline XML that does not explicitly set its XmlNamespace (xmlns="")"
<XmlDataProvider x:Key="MoreColors" XPath="/colors">
<x:XData>
<colors xmlns="" >
<color name="pink"/>
<color name="white"/>
<color name="black"/>
<color name="cyan"/>
<color name="gray"/>
<color name="magenta"/>
</colors>
</x:XData>
</XmlDataProvider>
Any idea? Thanks
dev
|
|
|
|
|
I reproduced your code but it works fine here without any issues. Have you inserted this code inside a resources tag? Eg:
<Grid.Resources>
<XmlDataProvider x:Key="MoreColors" XPath="/colors">
<x:XData>
<colors xmlns="" >
<color name="pink"/>
<color name="white"/>
<color name="black"/>
<color name="cyan"/>
<color name="gray"/>
<color name="magenta"/>
</colors>
</x:XData>
</XmlDataProvider>
</Grid.Resources>
|
|
|
|
|
I almost never use ToString(), but when I do, its for a representation of the entire object. The DataTemplate is binding to a single property (or multiple ones with a value converter).
|
|
|
|
|
DataTemplate is actually often used for the represantation of the entire object, arbitrarily complex (both the object and the representation).
|
|
|
|
|
If I only need to show 1 value in my combobox I normally just set the DisplayMemberPath of the combobox to the property I want to show.
It is said that your life flashes before your eyes just before you die. That is true, it's called Life. - Terry Pratchett
|
|
|
|
|
I would say that ToString "converts" the whole object to a string, simple as that. Which means 1) you can't return any fancy colorful represantation other than a simple string and 2) the ToString() is global application-wise, meaning that you can't make two comboboxes displaying the same list of items make display slightly different things (which you can do with DataTamplates).
DataTemplates are much more versatile, can be specific for a particular control (combobox) or used globally. They can also display much more complex data than just a string.
Then there are value converters...
The call is yours, ToString may be just fine for simple combobox item represatation, setting ItemTemplate doesn't hurt either.
|
|
|
|
|
I wasn't wrong, just not really answering your question, sorry for that. I just wanted to outline the main differences between the two approaches, which is not really what you asked. Ad 1) sure, VM does not return colors, what I had in mind was a rather more complex object than just DisplayName and then ToString() forces you to condense all the data to one string, which can be very limiting and styling is of no help. Ad 2) of course you can use DataTemplates but I was talking about limitations of ToString().
|
|
|
|
|
Not an answer to your question but a comment. You mention Label as a means to display a string, I'll suggest you use TextBlock instead as Label is not much more than a wrapper around TextBlock . Label Only adds the ability to add a border and using an access key, both you can do with out using a Label .
See Josh Smiths discussion about Label and TextBlock Differences between Label and TextBlock[^]
|
|
|
|
|
You may find that this thread[^] covers what's happening and suggests an appropriate solution (the TabControlEx code).
|
|
|
|
|
I want to display a license version in a TextBox from a property and do it with bindings.
There are two buttons to switch between different license versions and a TextBox to display the license version.
Here is the XAML code:
<Window x:Class="WpfApplication1.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">
<StackPanel Orientation="Vertical">
<TextBox Name="txtVersion" Text="????"></TextBox>
<Button Content="Version 1" Click="Version1_Click"></Button>
<Button Content="Version 2" Click="Version2_Click"></Button>
</StackPanel>
</Window>
Notice the TextBox Text property, which I don't know how to bind.
The C# code is:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApplication1
{
public partial class MainWindow : Window, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
License license1;
License license2;
public MainWindow()
{
InitializeComponent();
license1 = new License("Version 1");
license2 = new License("Version 2");
License.Current = license1;
this.DataContext = this;
this.PropertyChanged += new PropertyChangedEventHandler(MainWindow_PropertyChanged);
}
void MainWindow_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
}
private void Version1_Click(object sender, RoutedEventArgs e)
{
License.Current = license1;
PropertyChanged(this, new PropertyChangedEventArgs("Version"));
}
private void Version2_Click(object sender, RoutedEventArgs e)
{
License.Current = license2;
PropertyChanged(this, new PropertyChangedEventArgs("Version"));
}
}
class License
{
static License current;
string version;
public License(string version)
{
this.version = version;
}
public static License Current
{
get { return current; }
set { current = value; }
}
public string Version
{
get { return version; }
}
}
}
The class License has the static instance Current property which always give me access to the current Licence. With this I can access the current version like: License.Current.Version
So how do I bind the TextBox's Text to that?
I try also to display the version number every time I press either of the buttons. Is this a working solution?
|
|
|
|
|
Your binding simply needs to be "{Binding Version}" to bind to the version, providing you add a Version property into your window, e.g.
public string Version { get { return License.Current.Version; } }
|
|
|
|
|
That doesn't work. Crashes with an InvalidOperationException. "A TwoWay or OneWayToSource binding cannot work on the read-only property 'Version' of type 'WpfApplication1.MainWindow'."
I changed the property in the Window and it worked just fine.
public string Version
{
get { return License.Current.Version; }
set { string s = value; }
}
But I'm looking for the WPF binding to reach the Version Property in the License class through the static instance Current of License class. Instead of bind to my Window class.
If it's possible...
|
|
|
|
|
Mc_Topaz wrote: "A TwoWay or OneWayToSource binding cannot work on the read-only property 'Version' of type 'WpfApplication1.MainWindow'."
I changed the property in the Window and it worked just fine.
Wrong fix... Don't put in a dummy setter... Just change the binding to: {Binding Version,Mode=OneWay}
But anyway, you CAN bind to static classes, but you might have trouble with an inner class...
Example:
<TextBlock Text ="{Binding Source={x:Static local:MyStaticClass.MyProperty}}"/>
(From here[^])
|
|
|
|
|
Thanks, I changed the XAML.
But I don't use a static class. I use a static INSTANCE of the same class to reach a property within the class which is not static.
|
|
|
|
|
Hmm, good point... Need more caffeine... So Pete's solution is the best bet, with that OneWay tweak.
|
|
|
|
|
Sorry, I should have mentioned that you would set your binding as Mode=OneWay . As it currently stands, your code cannot do this because License is not a property in your DataContext. This means that while your code-behind can see it, the XAML cannot. To overcome this from your main window, you need to expose a property that can be bound to.
|
|
|
|