|
I'm working on a timeline control similar to this
How would you create the "thumb" in the center? What control would be best, and how would you style it?
Anyone done anything like this? Any examples?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I have a random error that crashes my WPF application. It generally happens when navigating between views. There are numerous try/catch wrappers but it manages to avoid all of these.
This seems to be the most relevant information but I do not know how to research or interpret it. Any suggestions would be appreciated.
<problemsignatures>
<eventtype>CLR20r3
<parameter0>IssuanceUAT.exe
<parameter1>2.0.2.0
<parameter2>58d338db
<parameter3>PresentationFramework
<parameter4>4.6.1055.0
<parameter5>563c1d45
<parameter6>789c
<parameter7>44
<parameter8>System.IO.IOException
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Navigation error to a non existing page.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I have the busiest WPF form I have ever created, 23 combo boxes, 35 text boxes or date pickers and a bunch of buttons and that is just the first tab, there are 10 other tabs with lists and user controls. All user controls are lazy loaded when the tab is selected.
There is a load of automation on the form where 1 action filters/disables 1 or more controls.
I load the data using a BGW thread and that is fast and consistent. The data is loaded into a local object and when the loading is complete I bind the selected object
SelectedObject = LocalObject
The binding is initially resonably fast, sub 1 second, this blows out to 8+ seconds with subsequent page loads. The delay seems to be caused by binding the SelectedObject to the LocalObject (the delay is so huge it can easily be tracked to that line of code).
Any suggestions how I can alleviate the delay problem when binding.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi there,
I have a DataGrid with it's content stored in a List<>. I'm able to format cells depending on the data of ONE other cell using a value converter.
Here is the my MainWindow.xaml:
<Window x:Class="Test_WpfGrid.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:Test_WpfGrid"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<local:CBrushConverter x:Key="BrushConverter"/>
</Window.Resources>
<Grid>
<DataGrid x:Name="grdPeople" Margin="5,5,5,5" AutoGenerateColumns="False" SelectionMode="Single" SelectionUnit="FullRow">
<DataGrid.Columns>
<DataGridTextColumn Width="150" Binding="{Binding FName}" Header="First Name">
<DataGridTextColumn.ElementStyle>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Background" Value="{Binding Age, Converter={StaticResource BrushConverter}}" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Width="150" Binding="{Binding LName}" Header="Last Name">
<DataGridTextColumn.ElementStyle>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Background" Value="{Binding Age, Converter={StaticResource BrushConverter}}" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Width="50" Binding="{Binding Age}" Header="Age" />
<DataGridTextColumn Width="50" Binding="{Binding DisplState}" Header="State" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</Window>
And this is the MainWindow.xaml.cs:
namespace Test_WpfGrid
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
List<CPerson> People = new List<CPerson>();
People.Add(new CPerson("John", "Doe", 25, 2));
People.Add(new CPerson("Jane", "Doe", 52, 4));
People.Add(new CPerson("Jenny", "Doe", 14, 0));
People.Add(new CPerson("Sammy", "Doe", 24, 3));
People.Add(new CPerson("Paul", "Smith", 10, 3));
grdPeople.ItemsSource = People;
}
}
}
Data is stored in a List<cperson> with the following class:
namespace Test_WpfGrid
{
public class CPerson
{
public string FName { get; set; }
public string LName { get; set; }
public int Age { get; set; }
public int State { get; set; }
public string DisplState
{
get { return (this.State > 0) ? this.State.ToString() : "undef"; }
}
public CPerson(string FName, string LName, int Age, int State)
{
this.FName = FName;
this.LName = LName;
this.Age = Age;
this.State = State;
}
}
}
And finally here is my value converter class:
namespace Test_WpfGrid
{
public class CBrushConverter : IValueConverter
{
private Color[] mBGColors = { Color.FromArgb(255, 224, 224, 224),
Color.FromArgb(255, 255, 155, 155),
Color.FromArgb(255, 200, 240, 200)
};
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
int Age = (int)value;
System.Windows.Media.Brush Brush = new SolidColorBrush(this.mBGColors[(Age >= 18) ? 2 : ((Age >= 12) ? 1 : 0)]);
return Brush;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
}
}
With this code the columns for FName and LName are formated with a specific background color, depending on the value of the Age-property.
Now I want to format the two columns depeding on the values of Age AND State.
Is this possible?
What has to be changed in my code?
Thanks for your help!
|
|
|
|
|
|
Thanks for your help. It works fine now.
|
|
|
|
|
I feel quite defeated and overwhelmed at present. Apologies if this is done incorrectly. Any assistance would be warmly welcomed.
I'm writing a program in WPF, using c#, which should collect inputs via relevant textbox fields. These inputs should filter through to my sql command parameters, where I can then run the stored procedure. Then the info should populate back into a Datagrid in WPF mainwindow.
Basically, searching through historical stock pricing, returning all info between date, price, volume, etc, based on whichever values the user selects.
My SQL stored procedure returns expected values. The only way I can get my program to return the same values is to hardcode each input. I know I am missing the link between getting the values from each textbox into the SQL command parameters, but I'm at a loss as to how to do this. I think I need to set an event in my "mainwindow.xaml.cs" but I just cannot work out the right syntax...
<pre>namespace MBM3._0
{
public partial class MainWindow : Window
{
StockValues src = new StockValues();
public MainWindow()
{
InitializeComponent();
Loaded += MainWindow_Loaded;
this.DataContext = src;
}
public void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
textBoxStockSymbol.Text = "AEA";
textBoxDateFrom.Text = "2000-01-03";
textBoxDateTo.Text = "2010-02-08";
textBoxSPOpenFrom.Text = "0";
textBoxSPOpenTo.Text = "50";
textBoxSPCloseFrom.Text = "50";
textBoxSPCloseTo.Text = "50";
textBoxSPACloseFrom.Text = "50";
textBoxSPACTo.Text = "50";
textBoxSPHighFrom.Text = "50";
textBoxSPHighTo.Text = "50";
textBoxSPLowFrom.Text = "50";
textBoxSPLowTo.Text = "50";
textBoxSVolumeFrom.Text = "50";
textBoxSVolumeTo.Text = "50";
}
private void dataGrid_Loaded(object sender, RoutedEventArgs e)
{
}
private void buttonFind_Click(object sender, RoutedEventArgs e)
{
try
{
DataTable MSQ = DataLayer.Stock.MSQ("WPFDemo App");
dataGrid.ItemsSource = MSQ.DefaultView;
}
catch (SqlException sqlex)
{
MessageBox.Show("Error: " + sqlex.Message, "Exception Sample", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
private void textBoxStockSymbol_TextChanged(object sender, TextChangedEventArgs e)
{
}
}
}
And Stock Layer
<pre>namespace DataLayer
{
public class Stock
{
public static DataTable MSQ(string appName)
{
DataTable table1 = new DataTable();
SqlDataAdapter da1 = new SqlDataAdapter();
StockValues sv = new StockValues();
using (SqlConnection conn = Database.GetSqlConnection())
{
SqlCommand cmd = new SqlCommand("SELECT date, stock_symbol, stock_price_open, stock_price_close, stock_price_lo, stock_price_high, stock_price_adj_close, stock_volume FROM NYSE WHERE date BETWEEN @date_from AND @date_to AND stock_symbol LIKE @stock_symbol AND stock_price_open BETWEEN @stock_price_open_from AND @stock_price_open_to AND stock_price_close BETWEEN @stock_price_close_from AND @stock_price_adj_close_to AND stock_price_lo BETWEEN @stock_price_lo_from AND @stock_price_lo_to AND stock_price_high BETWEEN @stock_price_high_from AND @stock_price_high_to AND stock_price_adj_close BETWEEN @stock_price_adj_close_from AND @stock_price_adj_close_to AND stock_volume BETWEEN @stock_volume_from AND @stock_volume_to", conn);
cmd.Parameters.Add(new SqlParameter("date_from", System.Data.SqlDbType.Date));
cmd.Parameters.Add(new SqlParameter("date_to", System.Data.SqlDbType.Date));
cmd.Parameters.Add(new SqlParameter("stock_symbol", System.Data.SqlDbType.VarChar));
cmd.Parameters.Add(new SqlParameter("stock_price_open_from", System.Data.SqlDbType.Float));
cmd.Parameters.Add(new SqlParameter("stock_price_open_to", System.Data.SqlDbType.Float));
cmd.Parameters.Add(new SqlParameter("stock_price_close_from", System.Data.SqlDbType.Float));
cmd.Parameters.Add(new SqlParameter("stock_price_close_to", System.Data.SqlDbType.Float));
cmd.Parameters.Add(new SqlParameter("stock_price_lo_from", System.Data.SqlDbType.Float));
cmd.Parameters.Add(new SqlParameter("stock_price_lo_to", System.Data.SqlDbType.Float));
cmd.Parameters.Add(new SqlParameter("stock_price_high_from", System.Data.SqlDbType.Float));
cmd.Parameters.Add(new SqlParameter("stock_price_high_to", System.Data.SqlDbType.Float));
cmd.Parameters.Add(new SqlParameter("stock_price_adj_close_from", System.Data.SqlDbType.Float));
cmd.Parameters.Add(new SqlParameter("stock_price_adj_close_to", System.Data.SqlDbType.Float));
cmd.Parameters.Add(new SqlParameter("stock_volume_from", System.Data.SqlDbType.Int));
cmd.Parameters.Add(new SqlParameter("stock_volume_to", System.Data.SqlDbType.Int));
cmd.Parameters["date_from"].Value = "2000-01-03";
cmd.Parameters["date_to"].Value = "2010-02-08";
cmd.Parameters["stock_symbol"].Value = "%";
cmd.Parameters["stock_price_open_from"].Value = "50";
cmd.Parameters["stock_price_open_to"].Value = "50";
cmd.Parameters["stock_price_close_from"].Value = "0";
cmd.Parameters["stock_price_close_to"].Value = "500";
cmd.Parameters["stock_price_lo_from"].Value = "0";
cmd.Parameters["stock_price_lo_to"].Value = "500";
cmd.Parameters["stock_price_high_from"].Value = "0";
cmd.Parameters["stock_price_high_to"].Value = "500";
cmd.Parameters["stock_price_adj_close_from"].Value = "0";
cmd.Parameters["stock_price_adj_close_to"].Value = "500";
cmd.Parameters["stock_volume_from"].Value = "0";
cmd.Parameters["stock_volume_to"].Value = "1000000000";
da1 = new SqlDataAdapter(cmd);
da1.Fill(table1);
}
return table1;
}
}
}
public class StockValues
{
public DateTime date_from { get; set; }
public DateTime date_to { get; set; }
public string stock_symbol { get; set; }
public float stock_price_open_from { get; set; }
public float stock_price_open_to { get; set; }
public float stock_price_close_from { get; set; }
public float stock_price_close_to { get; set; }
public float stock_price_lo_from { get; set; }
public float stock_price_lo_to { get; set; }
public float stock_price_high_from { get; set; }
public float stock_price_high_to { get; set; }
public float stock_price_adj_close_from { get; set; }
public float stock_price_adj_close_to { get; set; }
public int stock_volume_from { get; set; }
public int stock_volume_to { get; set; }
}
|
|
|
|
|
You'll need to modify your MSQ method to accept the parameters. It looks like your StockValues class is intended to hold the parameter values.
public static DataTable MSQ(StockValues sv)
{
using (SqlConnection conn = Database.GetSqlConnection())
using (SqlCommand cmd = new SqlCommand("SELECT date, stock_symbol, stock_price_open, stock_price_close, stock_price_lo, stock_price_high, stock_price_adj_close, stock_volume FROM NYSE WHERE date BETWEEN @date_from AND @date_to AND stock_symbol LIKE @stock_symbol AND stock_price_open BETWEEN @stock_price_open_from AND @stock_price_open_to AND stock_price_close BETWEEN @stock_price_close_from AND @stock_price_adj_close_to AND stock_price_lo BETWEEN @stock_price_lo_from AND @stock_price_lo_to AND stock_price_high BETWEEN @stock_price_high_from AND @stock_price_high_to AND stock_price_adj_close BETWEEN @stock_price_adj_close_from AND @stock_price_adj_close_to AND stock_volume BETWEEN @stock_volume_from AND @stock_volume_to", conn))
{
cmd.Parameters.AddWithValue("@date_from", sv.date_from);
cmd.Parameters.AddWithValue("@date_to", sv.date_to);
cmd.Parameters.AddWithValue("@stock_symbol", sv.stock_symbol);
cmd.Parameters.AddWithValue("@stock_price_open_from", sv.stock_price_open_from);
cmd.Parameters.AddWithValue("@stock_price_open_to", sv.stock_price_open_to);
cmd.Parameters.AddWithValue("@stock_price_close_from", sv.stock_price_close_from);
cmd.Parameters.AddWithValue("@stock_price_close_to", sv.stock_price_close_to);
cmd.Parameters.AddWithValue("@stock_price_lo_from", sv.stock_price_lo_from);
cmd.Parameters.AddWithValue("@stock_price_lo_to", sv.stock_price_lo_to);
cmd.Parameters.AddWithValue("@stock_price_high_from", sv.stock_price_high_from);
cmd.Parameters.AddWithValue("@stock_price_high_to", sv.stock_price_high_to);
cmd.Parameters.AddWithValue("@stock_price_adj_close_from", sv.stock_price_adj_close_from);
cmd.Parameters.AddWithValue("@stock_price_adj_close_to", sv.stock_price_adj_close_to);
cmd.Parameters.AddWithValue("@stock_volume_from", sv.stock_volume_from);
cmd.Parameters.AddWithValue("@stock_volume_to", sv.stock_volume_to);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable table = new DataTable();
da.Fill(table);
return table;
}
}
In your buttonFind_Click method, you'll need to create an instance of the StockValues class, populate it from the textbox values, and then pass it to the MSQ method.
private void buttonFind_Click(object sender, RoutedEventArgs e)
{
try
{
StockValues sv = new StockValues
{
stock_symbol = textBoxStockSymbol.Text
};
DateTime date;
if (DateTime.TryParse(textBoxDateFrom.Text, out date))
{
sv.sv.date_from = date;
}
if (DateTime.TryParse(textBoxDateTo.Text, out date))
{
sv.date_to = date;
}
float valueFloat;
if (float.TryParse(textBoxSPOpenFrom.Text, out valueFloat))
{
sv.stock_price_open_from = valueFloat;
}
if (float.TryParse(textBoxSPOpenTo.Text, out valueFloat))
{
sv.stock_price_open_to = valueFloat;
}
if (float.TryParse(textBoxSPCloseFrom.Text, out valueFloat))
{
sv.stock_price_close_from = valueFloat;
}
if (float.TryParse(textBoxSPCloseTo.Text, out valueFloat))
{
sv.stock_price_close_to = valueFloat;
}
if (float.TryParse(textBoxSPLowFrom.Text, out valueFloat))
{
sv.stock_price_lo_from = valueFloat;
}
if (float.TryParse(textBoxSPLowTo.Text, out valueFloat))
{
sv.stock_price_lo_to = valueFloat;
}
if (float.TryParse(textBoxSPHighFrom.Text, out valueFloat))
{
sv.stock_price_high_from = valueFloat;
}
if (float.TryParse(textBoxSPHighTo.Text, out valueFloat))
{
sv.stock_price_high_to = valueFloat;
}
if (float.TryParse(textBoxSPACloseFrom.Text, out valueFloat))
{
sv.stock_price_adj_close_from = valueFloat;
}
if (float.TryParse(textBoxSPACTo.Text, out valueFloat))
{
sv.stock_price_adj_close_to = valueFloat;
}
int valueInt;
if (int.TryParse(textBoxSVolumeFrom.Text, out valueInt))
{
sv.stock_volume_from = valueInt;
}
if (int.TryParse(textBoxSVolumeTo.Text, out valueInt))
{
sv.stock_volume_to = valueInt;
}
DataTable MSQ = DataLayer.Stock.MSQ(sv);
dataGrid.ItemsSource = MSQ.DefaultView;
}
catch (SqlException sqlex)
{
MessageBox.Show("Error: " + sqlex.Message, "Exception Sample", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
@Richardd Deeming.
Richard, you sir, are my new hero! Can't thank you enough.
I did wake up this morning to give it another crack but still couldn't get it to work. Then i read your response. Perfect!
I was having an issue with the Date field coming up "out of range" but for now I have simply converted these to textfields. Work's a treat.
Can't thank you enough. I can now see where things slot into place. I had watched and rewatched hours of vid but as they were not quite the same as to what I was doing it was hard to visualise.
You have helped me immensely!!
|
|
|
|
|
I only get this error on IE. The app works fine in Chrome.
Here's the JS
<script src="/Scripts/jquery-3.1.1.min.js"></script>
<script src="/Scripts/jquery.signalR-2.1.2.js"></script>
<script src="/signalr/hubs"></script>
<script type="text/javascript">
$(function () {
<pre>
var proxy = $.connection.DashboardHub;
proxy.client.NotifyAllClientsOfChanges = function () {
var searchUrl = "Home/GetData";
$.ajax({
url: searchUrl,
type: "POST",
success: function (data) {
$("#divData").html(data);
}
});
};
});
When I run the file jquery-3.1.1.min.js opens, and this is highligted:
h=a.indexOf(" ")
and I get the error "Object doesn't support property or method 'indexOf'"
Google results say that IE doesn't support this. Anyone heard of this? Any way to make this work?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Why are you posting all of these Javascript questions in the WPF forum, when there's a perfectly good JavaScript forum[^] you could use?
And you might want to mention which version of IE you're running, and which document mode it's running in. The Array.prototype.indexOf()[^] method is supported in IE9 and later, so it looks like you're either using IE8 or earlier, or you're stuck in an old document mode.
Emulate browsers, screen sizes, and GPS locations (Windows)[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: Why are you posting all of these Javascript questions in the WPF forum
Because I'm an idiot and didn't realize I was.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I'm using IE 11.
Richard Deeming wrote: or you're stuck in an old document mode.
Can you elaborate? Not sure what that means.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Open the developer tools (F12) and select the "Emulation" tab. Look at the value in the "Document mode" list - if it's not "11" or "Edge", then you're emulating an older version of IE.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
See my previous posting
When I run my app I get the exception
"jQuery was not found. Please ensure jQuery is referenced before the SignalR client JavaScript file."
This occurs at the top of the SignalR proxy file:
jquery.signalR-2.2.1.js
if (typeof ($) !== "function") {
throw new Error(resources.nojQuery);
}
In my view I have:
<body>
<pre>
<!--Reference the jQuery library. -->
<script src="Scripts/jquery-1.10.2.min.js" "></script>
<!--Reference the SignalR library. -->
<script src="/Scripts/jquery.signalR-2.2.1.js"></script>
<!--Reference the autogenerated SignalR hub script. -->
<script src="/signalr/hubs"></script>
<script type="text/javascript">
$(function () {
var proxy = $.connection.DashboardHub;
proxy.client.NotifyAllClientsOfChanges = function () {
var searchUrl = "Home/GetData";
$.ajax({
url: searchUrl,
type: "POST",
success: function (data) {
$("#divData").html(data);
}
});
};
});
So JQuery IS being referenced first... unless the word 'reference' means something else here.
What am I doing wrong?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Does the file jquery-1.10.2.min.js exist?
Why are you working with such an old version of jQuery anyway?
The current version is 3.something I think.
The latest minor version of version 1 is 12, so 1.10 is old even for jQuery 1 standards
|
|
|
|
|
Sander Rossel wrote: Does the file jquery-1.10.2.min.js exist?
Yes
Sander Rossel wrote: Why are you working with such an old version of jQuery anyway?
Because I don't know any better.
Sander Rossel wrote: The current version is 3.something I think.
Think it would make a difference here?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I'm not sure whether you've messed up your formatting again or if that is your actual code, but you have an extra " in your jquery script tag.
Just noticed that now and it may be your problem.
|
|
|
|
|
Got it working!!
1) Doesn't work on IE.. Stumbled upon this by Googling another error message "Object doesn't support property or method 'indexOf'"
2) Updated jquery and signalr to latest
3) Fixed that format error. There was indeed an extra "
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
|
The path is wrong. You have /Scripts for signalR (which is clearly running since you get the error from it) but you have just Scripts (note the missing / ) for jquery. Hence, the jQuery file is not being loaded.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
What should it be? It's relative from where?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Kevin Marois wrote: It's relative from where? From where the code executes.
Kevin Marois wrote: What should it be? Since signalR.js is getting loaded then /Scripts must be correct.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Got it working!!
1) Doesn't work on IE.. Stumbled upon this by Googling another error message "Object doesn't support property or method 'indexOf'"
2) Updated jquery and signalr to latest
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|