|
You have his e-mail then....
|
|
|
|
|
I can try.. Did you see the date on that page.. 24 Oct 07
If it's not broken, fix it until it is
|
|
|
|
|
|
That's a blog pointing to the page with the source. The source page is 2007. The download link doesn't work.
I'll email the blogger, but I think it's a stretch.
If it's not broken, fix it until it is
|
|
|
|
|
I'm going to be controlling a camera... tilt/pan/zoom.
Anyone know of a joystick type of control for use in WPF? Something that looks like the little joystick on a game controller would be nice.
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
|
I created a WPF (.Net 4) UserControl containing some ComboBoxes and a TextBox. In XAML, some ValidationRules are bound to the TextBox. If the TextBox contains invalid data, a red frame is shown, and the tooltip is set to the error description. Works well.
Next, I placed two instances of that UserControl on a form, and added a button. In XAML, the button is connected to a RelayCommand of the ViewModel. Now I want the button to be enabled only when both of the UserControls contain valid data only.
Not a problem, I thought, let me use a strategy which works elsewhere. I added a trigger:
<Button Content="_OK" ... Command="{Binding Path=OKCommand}">
<Button.Style>
<Style TargetType="{x:Type Button}">
<Setter Property="IsEnabled" Value="false" />
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ElementName=cascadingComboFrom, Path=(Validation.HasError)}" Value="false" />
<Condition Binding="{Binding ElementName=cascadingComboTo, Path=(Validation.HasError)}" Value="false" />
</MultiDataTrigger.Conditions>
<Setter Property="IsEnabled" Value="true" />
</MultiDataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
But there is a catch: Validation.HasError is always false for the UserControls - the Validation failed for an element inside the UserControl, not for the UserControl proper.
I know that I can register the Click event of the button, check the validity there using the method shown in http://stackoverflow.com/questions/127477/detecting-wpf-validation-errors[^], and prevent the execution of the RelayCommand by setting the Handled property of the RoutedEventArgs to true. But that looks more like WTF than WPF.
What do you suggest? How can I retrieve the Validation Errors of the UserControl's children? Or how can I get them in the RelayCommand's CanExecute method? Or some other tricks?
|
|
|
|
|
Rather than basing your validation on the UI, it's helpful to base it on the underlying ViewModel instead. A relatively simplistic approach is outlined in this[^] article.
|
|
|
|
|
There is another catch: the TextBox is bound to an int property. If the user enters "abc", updating the int property of the UserControl fails.
|
|
|
|
|
That's not a problem. That's precisely the type of thing a ViewModel is designed to solve. Have a property backing your TextBox of type string, and then test the input there. Only pass the value on if it's an int. Alternatively, back it with a Behavior[^] to ensure the user cannot enter invalid values.
|
|
|
|
|
Thanks for the hint. I'll look into that approach.
The vaildation errors occur in the realm of the UserControl, while the Button and its command are in the realm of the Window (and its ViewModel, resp.). Things will become more complicated, but I'll try it.
|
|
|
|
|
Drop that Behavior on the TextBox and you won't need to reject ABC... because that's taken care of for you.
|
|
|
|
|
|
I have a WPF control hosted in an ElementHost in a WinForms control.
My WPF control has 5 buttons on top, a horizontal separator, and a ListBox below. The buttons have simple stlyes and images.
When I put the WPF control on a WinForms control, and also in runtime, the images and styles do not appear. The buttons appear as skinny verticle "slivers"
I've never hosted a WPF control in WinForms before. Does anyone have any idea why this is happening?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
I'm converting parts of a WinForms app to WPF.
This code is a PictureBox that has a circular area in the middle. The Paint event is used to color the circle. Then later a transparent icon is placed over it. The color is user-configurable.
Here's the WinForms control code:
public partial class ucFC6SensorPictureBox : PictureBox
{
private Color _BackgroundColor = Color.Yellow;
public Color BackgroundColor
{
get
{
return _BackgroundColor;
}
set
{
_BackgroundColor = value;
Refresh();
}
}
public ucFC6SensorPictureBox()
{
InitializeComponent();
}
private void ucFC6SensorPictureBox_Paint(object sender, PaintEventArgs e)
{
using (SolidBrush b = new SolidBrush(_BackgroundColor))
{
e.Graphics.FillEllipse(b, 1F, 1F, this.ClientRectangle.Width - 2F, this.ClientRectangle.Height - 2F);
}
if (Image != null)
{
e.Graphics.DrawImage(Image, new Point(0, 0));
}
}
}
Mu question is how to do this In WPF.
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
Something like this should do it
<Grid Width="200" Height="200">
<Ellipse HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Fill="{Binding UserDefinedColor}" />
<Image Source="{Binding ImageSource}" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Grid>
|
|
|
|
|
I need to design a time scale control that scrolls horizontally. Think of a ruler with vertical lines for hours, minutes, and seconds that moves right to left as time tics.
Here's a basic idea[^]
Requirements:
- The user can decide to show Hours, Minutes, or Seconds, or all three.
- The content needs to scroll in relation to the scale shown... meaning if Minutes is selected, then every minute the scale needs to move from right to left the "width" of the space of one minute bar. The more ticks shown (seconds), the faster it moves.
- The content area needs to be dragable. Once dragging is done, the control should resume responding to timer events.
- There has to be a vertical bar that represents "now", and that bar should always be in the center. This should not be an issue since the control is moving in real time, so the center should always be the now position.
- There will be dots added to the control in real time that represent event that occurred. Clicking the dot will invoke some other action. (Don't need to code that action right now, just the dots appearing)
- I'd like to provide the option for smooth scrolling or incremental scrolling. This would probably be done using a constant motion for smooth scrolling and for incremental, it would move in response to a timer tic.
I have some ideas on how to design this, but I'd like to get some input before I start.
I've looked at this control[^] but it looks overly complex for what I want.
Thanks
If it's not broken, fix it until it is
modified 22-Apr-15 15:03pm.
|
|
|
|
|
Telerik have a timeline type control but the only time I considered it I found it dramatically over the top with functionality. I would have spent more time customising it to meet my simple needs (chopping bits out) than building a control from scratch. It may be worth looking at for your requirements.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
[SOLVED]
Found this[^]
I'm trying to create a user control that has a timer:
using System;
using System.Timers;
using System.Windows;
using System.Windows.Controls;
namespace WpfApplication1
{
public partial class Timeline : UserControl
{
Timer timer = null;
public string CurrentTime
{
get { return (string)GetValue(CurrentTimeProperty); }
set { SetValue(CurrentTimeProperty, value); }
}
public static readonly DependencyProperty CurrentTimeProperty =
DependencyProperty.Register("CurrentTime", typeof(string), typeof(Timeline), new PropertyMetadata(""));
public Timeline()
{
InitializeComponent();
setup();
}
private void setup()
{
timer = new Timer();
timer.Elapsed += timer_Elapsed;
timer.Interval = 1000;
timer.Enabled = true;
}
private void timer_Elapsed(object sender, ElapsedEventArgs e)
{
CurrentTime = DateTime.Now.TimeOfDay.ToString();
}
}
}
When I run this it fires after 1 second, and I get a runtime exception on the DP Setter:
The calling thread cannot access this object because a different thread owns it.
I don't understand why it thinks this is in a different thread. What am I not seeing ehre?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
OnMouseDoubleClick from a selectedItem in a listview, I want to retrieve the parent of that selectedItem, and from that, populate several related listviews with the related records.
What is the best way to do this using the MVVM pattern without polluting the view with too much code-behind?
|
|
|
|
|
I hope you get a response for this as I'm a polluter, I use code behind and pass the info to the datacontext
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
The generally accepted solution is to use something like EventToCommand.
|
|
|
|
|
I'm pretty sure I told you how to do it when I answered you here[^].
|
|
|
|
|
please help to solve this issue.
Thanks in advance.
|
|
|
|
|
Err, I'm not exactly sure what you're asking here. Are you talking about how to handle the change to the appropriate date format? What code do you currently have to handle the change of culture? Have you put the basics of i18n in place in your application already?
|
|
|
|