Am new to oxyplot and wish to use it with C# WPF with xaml. My .xaml file has the following code:
<code>
<Window x:Class="CurveMaster.MainWindow"
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:CurveMaster"
xmlns:oxy="http://oxyplot.org/wpf"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.DataContext>
<local:MainViewModel/>
</Window.DataContext>
<Grid>
<oxy:Plot Title="{Binding Title}">
<oxy:Plot.Series>
<oxy:LineSeries ItemsSource="{Binding Points}"/>
</oxy:Plot.Series>
</oxy:Plot>
</Grid>
</Window>
</code>
The .xaml.cs file is as follows:
<code>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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;
using OxyPlot;
namespace CurveMaster
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public class MainViewModel
{
public MainViewModel() //Constructor
{
this.Title = "My Graph";
this.Points = new List<DataPoint>
{
new DataPoint (0,4),
new DataPoint (10,13),
new DataPoint (20,15),
};
}
public string Title { get; private set; }
public IList <DataPoint> Points { get; private set; }
}
}
</code>
So I'm just trying to run the above simple example but get the following error messages in the xaml file:
The type 'oxy:Plot' was not found. Verify that you are not missing an assembly reference.
The name "MainViewModel" does not exist in the namespace "clr-namespace:CurveMaster".
Now I installed the oxyplot Nuget package for WPF and installation was successful. However, above tells me that the above two issues are both referencing issues but I cannot figure out what the problem is. What additional oxyplot referencing is required once the package is installed?
Secondly why does it give me the MainViewModel does not exist message when in fact it does exist in the CurveMaster namespace?
Thanks in advance.
If you (or someone else) still needs the answer - thats what helped me.
I also tried to install OxyPlot from Nuget and it gave referencing and non-existing errors. So I finally overpowered it with:
I have downloaded oxyplot from github, built it and took necessary DLL manually into my solution (OxyPlot.dll, OxyPlot.wpf.dll, OxyPlot.wpf.shared.dll)
I have changed
xmlns:oxy="http://oxyplot.codeplex.com"
to
xmlns:oxy="http://oxyplot.org/wpf"
in XAML.
Related
I have a most concise WPF program. The XAML interface is as follows. The code does not contain any other non automatically generated conten
enter image description here
He runs normally on my own computer, and the interface is as follows
enter image description here
But when I start this program on the client's computer, nothing is displayed
enter image description here
I use .NET Fremwork 4.8. The target platform uses x64. In order to prevent the problem of .NET, I use the same .Net framework generates a WinForms application. Its behavior and display are normal on the client computer, so I suspect this is a WPF problem
Do you have any similar problems and solutions
This is all the code
MainWindow.xaml
<Window x:Class="NET48TEST.MainWindow"
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:NET48TEST"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Label Content="此电脑可以运行有.NET 4.8框架开发的应用程序"/>
</Grid>
</Window>
MainWindow.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 NET48TEST
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}
Maybe you can try:
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
How are you running the client, release or debug mode?
try putting a background to the label and centralized
I need a little kickstart for creating a Visual Studio "Startpage" in the Version 2015.
There are old information (https://msdn.microsoft.com/en-us/library/Ee663382(v=vs.120).aspx) out there and some projects on Visual Studio Galery (eg "BetterStartPage" or "SolutionStartPage". Expecialy the "Custom Start Page Project Template" is out of date :-(
I do start a project with this tutorial: https://msdn.microsoft.com/en-us/library/ff425532(v=vs.140).aspx
But the steps and the information are quite ... short.
Here is my problem:
I compile the Custom Control Library project and following the manual installation steps mention in the article. I can select my custom start page, but it doesn't start my custom contol. The page is just empty. Its like the code in the DLL is not executed.
Here is the test-XAML file:
<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"
xmlns:MyNamespace="clr-namespace:StartPageControl;assembly=StartPageControl"
xmlns:vs="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.14.0"
xmlns:vsfx="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.14.0"
xmlns:MeineControls="clr-namespace:StartPageControl"
xmlns:local="clr-namespace:StartPageControl"
x:Class="StartPageControl.UserControl1"
mc:Ignorable="d"
Height="350" Width="525">
<Grid>
<Grid x:Name="LayoutGrid" >
<Button Click="Button_Click" Content="push me" Foreground="black" />
<Label x:Name="label" Content="Label" HorizontalAlignment="Left" Margin="720,171,-295,0" VerticalAlignment="Top" Width="100"/>
</Grid>
</Grid>
</UserControl>
UserControl1.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 StartPageControl
{
/// <summary>
/// Interaktionslogik für UserControl1.xaml
/// </summary>
public partial class UserControl1 : UserControl {
public UserControl1()
{
InitializeComponent();
ButtonApp ButtonApp1 = new ButtonApp();
LayoutGrid.Children.Add(ButtonApp1 as UIElement);
}
private void Button_Click(object sender, RoutedEventArgs e) {
label.Content = "Something happend!";
}
}
}
EDIT:
Here are the steps I did:
Creating a new WPF Control Libraby Project
Add a new XAML and add/change the namespaces
Add some "code behind" eg a Button with a Click-Event
Compile
Copy the XAML file in %USERPROFILE%\My Documents\Visual Studio 2015\StartPages\
Copy the Project .DLL in \Common7\IDE\PrivateAssemblies\
Start a new VS and choose the new Startpage
Getting the error (translated from german):
"System.Windows.Markup.XamlParseException" ... "Error creating 'Click' from Text 'Button_Click'"
..so I tried to use a UserControl in a UserControl (as you can see in the code above). There comes the the message "{clr-namespace:StartPageControl}ButtonApp can not be created"
:-( It seems to me, VS don't use the "Code Behind"/DLL...
I know it's a kind of diffuse question. Knows anybody a better startingpoint?
EDIT 2:
Paste all the Test-Code.
Foreword: I'm posting this here as I didn't get any replies to my post here: https://social.msdn.microsoft.com/Forums/vstudio/en-US/5d7d4554-7d4b-45af-b02c-22ed0c7695a2/navigation-in-c-xaml-not-working?forum=vsta
I know Stackoverflow is a much more reliable source, so I decided to repost it here.
I'm trying to make make my first app in VS, and I want it to just be an informational App about cubing (Solving Rubik's style cubes very fast.) I am just learning the basics of C# and XAML at the moment, but am unable to get navigation between pages. All tutorials I have seen say use the line of code:
this.Frame.Navigate(typeof(PLL), null);
But it gives me this error:
'Mainwindow' does not contain a definition for 'Frame' and no extension method 'Frame' accepting a first argument of type 'MainWindow' could be found (are you missing a using directive or an assembly reference?
I also want to point out that they say to use the 'Blank App' Template, but I can't seem to find that - is it not in VS community? Instead, I had to use the WPF app template.
What am I doing wrong? How can I get these links between pages working?
Below is the whole of my C# and XAML code.
Thanks!
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 CubingGuide
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void GoToPLL(object sender, RoutedEventArgs e)
{
this.Frame.Navigate(typeof(PLL), null);
}
}
}
XAML:
<Window x:Class="CubingGuide.MainWindow"
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:CubingGuide"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Button x:Name="GoToPLLButt" Margin="10,10,360,251" Content="PLL" Click="GoToPLL"/>
</Grid>
</Window>
You need to create Frame object in XAML if you want to navigate to the Frame(i.e. you need to populate the frame with your "PLL").
you need a Frame control in MainPage.xaml
<Window x:Class="WpfApplication1.MainWindow"
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:WpfApplication1"
xmlns:Controls="clr-namespace:System.Windows.Controls;assembly=PresentationFramework"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Button x:Name="button" Content="Button" HorizontalAlignment="Left" Height="60" Margin="64,89,0,0" VerticalAlignment="Top" Width="135" Click="button_Click"/>
<Controls:Frame Name="MainFrame" NavigationUIVisibility="Hidden" >
</Controls:Frame>
</Grid>
</Window>
On click event you just need to add this code:
private void button_Click(object sender, RoutedEventArgs e)
{
MainFrame.Navigate(new Page1());
}
I hope this helps :)
<Custom:Ribbon x:Name="ribbon" HorizontalAlignment="Left" Margin="0,10,0,0" VerticalAlignment="Top" Width="934">
<Custom:Ribbon.QuickAccessToolBar>
<Custom:RibbonQuickAccessToolBar>
<Custom:RibbonQuickAccessToolBar>
<Custom:RibbonSplitMenuItem Header="مرحله سوم"/>
</Custom:RibbonQuickAccessToolBar>
</Custom:Ribbon>
</Grid>
I have looked through past questions on this issue to no avail.
I've just created a new WPF project in VS 2013. I go to Add Reference, and select System.Windows.Form. It adds. Great!
However, the appropriate tools are still greyed out in the toolbox. Yes, auto-update toolbox is on. I've shown all. I've restarted VS and rebuilt my solution. I've added using System.Windows.Forms; to my MainWindow.xaml.cs file.
At this, I only have the bare bones code because this is a completely new project that I haven't touched yet.
What am I missing?? I've tried dragging the .dll file to the toolbox, tools are still greyed. Is there a piece of code I'm missing somewhere?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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;
using System.Windows.Forms;
namespace sub20tool3
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}
And:
<Window x:Class="sub20tool3.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:local="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
Title="MainWindow" Height="350" Width="525">
<Grid>
</Grid>
</Window>
You need a WindowsFormHost element to hold winforms controls in a WPF project. The WindowsFormHost also needs a reference to WindowsFormIntegration.
Here's a good tutorial on how to use them: http://www.wpf-tutorial.com/misc-controls/the-windowsformshost-control/
<Window x:Class="WpfTutorialSamples.Misc_controls.WindowsFormsHostSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
Title="WindowsFormsHostSample" Height="350" Width="450">
<Grid>
<WindowsFormsHost Name="wfhSample">
<WindowsFormsHost.Child>
<wf:WebBrowser DocumentTitleChanged="wbWinForms_DocumentTitleChanged" />
</WindowsFormsHost.Child>
</WindowsFormsHost>
</Grid>
</Window>
I am trying to write my own custom TextBox control in Silverlight 5.
I already have successfully written a custom label control, which I can reuse in my project.
The XAML and the code behind for the label control look like this.
The following code does work for me:
<sdk:Label
x:Class="Gui.CustomControls.LabelControl"
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:sw="clr-namespace:System.Windows;assembly=System.Windows"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
mc:Ignorable="d"
d:DesignHeight="25" d:DesignWidth="125">
<Grid x:Name="LayoutRoot" Background="White">
</Grid>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace Gui.CustomControls
{
public partial class LabelControl : System.Windows.Controls.Label
{
public LabelControl()
{
InitializeComponent();
}
}
}
Now I want to do the same for a TextBox - writing my own custom TextBox Control.
The code for the TextBox looks like this: As you may see, it is nearly the same thing
<sdk:TextBox
x:Class="Gui.CustomControls.TextBoxControl"
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:sw="clr-namespace:System.Windows;assembly=System.Windows"
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
mc:Ignorable="d"
d:DesignHeight="25" d:DesignWidth="125">
<Grid x:Name="LayoutRoot" Background="White">
</Grid>
</sdk:TextBox>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace Gui.CustomControls
{
public partial class TextBoxControl : System.Windows.Controls.TextBox
{
public TextBoxControl()
{
InitializeComponent();
}
}
}
While buliding the solution the following error occurs:
"The tag 'TextBox' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk'"
As the textbox control seems to live in the System.Windows.Controls.TextBox Namespace, I tried different namespaces in the XAML, but nothing worked.
My question is:
Which namespace do I have to use, to build this custom textbox?
If it's not a namespace problem, what am I missing?
Thank you.
It's not sdk:TextBox, just TextBox (i.e. http://schemas.microsoft.com/winfx/2006/xaml/presentation, which is the default xmlns in most XAML files). While oddly not documented on the Silverlight TextBox class, this is documented on the .NET 4.5 TextBox class.