Click here to Skip to main content
15,877,051 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Using custom fonts in WPF project Pin
Dave Kreskowiak15-Nov-21 1:43
mveDave Kreskowiak15-Nov-21 1:43 
QuestionCommon StackPanel being used in two places, with Horizontal and Vertical Orientations Pin
Amarnath S4-Nov-21 3:20
professionalAmarnath S4-Nov-21 3:20 
AnswerRe: Common StackPanel being used in two places, with Horizontal and Vertical Orientations Pin
Gerry Schmitz4-Nov-21 5:36
mveGerry Schmitz4-Nov-21 5:36 
GeneralRe: Common StackPanel being used in two places, with Horizontal and Vertical Orientations Pin
Amarnath S4-Nov-21 6:48
professionalAmarnath S4-Nov-21 6:48 
GeneralRe: Common StackPanel being used in two places, with Horizontal and Vertical Orientations Pin
Gerry Schmitz4-Nov-21 10:20
mveGerry Schmitz4-Nov-21 10:20 
QuestionVB.net - WPF - Help with treeview Pin
Lasse Frederiksen31-Oct-21 20:55
Lasse Frederiksen31-Oct-21 20:55 
AnswerRe: VB.net - WPF - Help with treeview Pin
Richard Deeming31-Oct-21 23:11
mveRichard Deeming31-Oct-21 23:11 
GeneralRe: VB.net - WPF - Help with treeview Pin
Lasse Frederiksen31-Oct-21 23:44
Lasse Frederiksen31-Oct-21 23:44 
GeneralRe: VB.net - WPF - Help with treeview Pin
Richard Deeming1-Nov-21 1:27
mveRichard Deeming1-Nov-21 1:27 
QuestionDataGridCell Style Problem Pin
Kevin Marois25-Oct-21 11:20
professionalKevin Marois25-Oct-21 11:20 
QuestionWPF MVVM Modeless Dialogs - any Example? Pin
Amarnath S23-Oct-21 21:08
professionalAmarnath S23-Oct-21 21:08 
AnswerRe: WPF MVVM Modeless Dialogs - any Example? Pin
Gerry Schmitz24-Oct-21 9:22
mveGerry Schmitz24-Oct-21 9:22 
GeneralRe: WPF MVVM Modeless Dialogs - any Example? Pin
#realJSOP9-Nov-21 23:24
mve#realJSOP9-Nov-21 23:24 
AnswerRe: WPF MVVM Modeless Dialogs - any Example? Pin
#realJSOP9-Nov-21 23:30
mve#realJSOP9-Nov-21 23:30 
QuestionHow do I create xy plots with WPF APP (.NET Framework)? --- Solved Pin
Member 1539432815-Oct-21 5:12
Member 1539432815-Oct-21 5:12 
AnswerRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Richard Deeming15-Oct-21 6:05
mveRichard Deeming15-Oct-21 6:05 
AnswerRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Gerry Schmitz15-Oct-21 9:23
mveGerry Schmitz15-Oct-21 9:23 
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Member 1539432815-Oct-21 9:28
Member 1539432815-Oct-21 9:28 
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Gerry Schmitz15-Oct-21 10:03
mveGerry Schmitz15-Oct-21 10:03 
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Member 1539432816-Oct-21 1:40
Member 1539432816-Oct-21 1:40 
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Eddy Vluggen16-Oct-21 3:13
professionalEddy Vluggen16-Oct-21 3:13 
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Gerry Schmitz16-Oct-21 9:46
mveGerry Schmitz16-Oct-21 9:46 
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? --- Solved Pin
Member 1539432817-Oct-21 4:44
Member 1539432817-Oct-21 4:44 
Solution:

Using the template on this web site - stackoverflow.com/questions/33756255/create-a-math-plot-in-c-sharp-xam

.xaml

<Canvas x:Name="gCanvasPlot0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="0,0,0,0"
Width="500"
Height="150" />

.cs

//------------------------------
private void AddPlot()
{
double dPI = Math.PI;

Polyline poXY = new Polyline {
Stroke = Brushes.Red
};
int iNumOfCycles = 3;
double dDeltaX = 0.01;
int iNumOfPoints0 = (int)(iNumOfCycles / dDeltaX);
for (int ii = 0; ii < iNumOfPoints0; ii++) {
double dX = ii * dDeltaX;
double dY = Math.Sin(2 * dPI * dX);
poXY.Points.Add(CorrespondingPoint(new Point(dX, dY), iNumOfCycles));
}
gCanvasPlot0.Children.Add(poXY);
}//AddPlot
//------------------------------
//------------------------------
private Point CorrespondingPoint(Point pt, int iNumOfCycles)
{
double dXmin = 0;
double dXmax = iNumOfCycles;
double dYmin = -1.1;
double dYmax = 1.1;
double dPlotWidth = dXmax - dXmin;
double dPlotHeight = dYmax - dYmin;

var poResult = new Point {
X = (pt.X - dXmin) * gCanvasPlot0.Width / (dPlotWidth),
Y = gCanvasPlot0.Height - (pt.Y - dYmin) * gCanvasPlot0.Height / (dPlotHeight)
};
return poResult;
}//CorrespondingPoint
//------------------------------

This works.

-- modified 18-Oct-21 11:02am.
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Gerry Schmitz17-Oct-21 11:30
mveGerry Schmitz17-Oct-21 11:30 
Question(xaml, wpf) ScrollViewer Binding confusion (beginner) Pin
Maximilien7-Oct-21 8:46
Maximilien7-Oct-21 8:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.