|
That is really a question for Microsoft to answer.
|
|
|
|
|
Microsoft recommends using HTML5 for web based applications. Silverlight is purely in maintenance mode now.
|
|
|
|
|
Never used them or stumble on any custom implementation of them.
Dunno why I need them! Nor how I should write them!
Any tips or explanation please?
|
|
|
|
|
Automation Peers allow us to programatically control UI elements from outside the application (i.e., to do things like automated UI testing).
|
|
|
|
|
|
[UPDATE]
Figured it out. Was binding to the event instead of the Handler
[UPDATE]
I created a user control with this event:
public partial class AssignedEmployeesControl : _BaseUserControl
{
public static readonly RoutedEvent AssignmentRemovedEvent =
EventManager.RegisterRoutedEvent("AssignmentRemoved",
RoutingStrategy.Bubble, typeof(RoutedEventHandler),
typeof(AssignedEmployeesControl));
public event RoutedEventHandler AssignmentRemoved
{
add { AddHandler(AssignmentRemovedEvent, value); }
remove { RemoveHandler(AssignmentRemovedEvent, value); }
}
protected void OnAssignmentRemoved()
{
RaiseEvent(new RoutedEventArgs(AssignmentRemovedEvent));
}
I then add my control to a DataGrid in another control
<DataGridTemplateColumn Header="Assigned Employees"
Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<vc:AssignedEmployeesControl EngineRef="{Binding
ElementName=employeeJobAssignmentsView, Path=EngineRef}"
AssignmentShift="{Binding Shift}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="AssignmentRemovedEvent">
<i:InvokeCommandAction
Command="{Binding ElementName=employeeJobAssignmentsView,
Path=AssignmentRemovedCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</vc:AssignedEmployeesControl>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
I then have a command to catch the event:
private ICommand _AssignmentRemovedCommand;
public ICommand AssignmentRemovedCommand
{
get
{
if (_AssignmentRemovedCommand == null)
_AssignmentRemovedCommand = new RelayCommand(p =>
assignmentRemovedExecuted(), p => assignmentRemovedCanExecute());
return _AssignmentRemovedCommand;
}
}
private bool assignmentRemovedCanExecute()
{
return true;
}
private void assignmentRemovedExecuted()
{
}
When I run it, my control calls OnAssignmentRemoved, but the host control's assignmentRemovedExecuted method never fires.
I get no compilation errors or ouput methods. I get no response at all.
Can anyone see what's wrong?
Thanks
If it's not broken, fix it until it is
modified 18-Dec-14 16:01pm.
|
|
|
|
|
First the main issue:
I have a Path that I create at runtime and show it on a custom control. This part works perfect. The visual tree is simple:
Control
-Line
-Control
--Grid
---Path
UseLayoutRound=True, SnapToDevicePixels=True. Line is a 1 pixel tall horizontal line and the user can customize the vertical position.
I need to stroke the path in two different colors. One color for above the line and one color for below the line. Typical solution I see is to use a 2 color brush. However, as you might suspect, it is *EXTREMELY CRITICAL* visually that the color change happen *EXACTLY* on the horizontal line. +/- 1 pixel is not acceptable.
The problem I'm having seems to be to align the color change on the line 100% of the time. For example, if my control is 99 pixels high and the threshold is at 50%, I should have 49 + 1 + 49.
I have tried the following solutions… problems I encountered are listed as well. Any way to get this working perfectly 100% of the time?
1) Vertical LinearGradientBrush
Generally works and hits the line 100% of the time, but it doesn’t give me a hard break between the two colors, so for example black going into white will leave a gray line
2a) DrawingBrush with RectangleGeometries
2b) DrawingBrush with DrawingContext
Both of these ideas have the same problem. I can’t hit the line 100% of the time (round off errors I’m guessing…) but I’m using the same math as with #1, so…
I can get a hard color change with both these, but I get +/- 1 pixel off errors…
|
|
|
|
|
My first thought would be to draw the line twice.
Once as a TWO pixel tall line in one color,
then again as a ONE pixel tall line in the other color, overwriting half of the line.
I don't know how accurately this would work...
A positive attitude may not solve every problem, but it will annoy enough people to be worth the effort.
|
|
|
|
|
The problem seems to be that DrawingBrush has round-off errors internally or it doesn't work the same way as the LinearGradientBrush in terms of origin / relative ratios. Like I said, LinearGradientBrush hits the line consistently with my "math". DrawingBrush isn't even consistent at 50% which should not even be suspectible to round-off errors since its a whole pixel. Sometimes its 1 pixel too high, sometimes its 1 pixel too low. Also tried TransformToVisual to go from the line to the path, but TransformToVisual considers both shapes to be the same height (as the height of the control), so it just maps the points 1 to 1. Tried Math.Round() and Math.Ceiling(), etc. LOL. The line itself certainly doesn't move around, its always at the exact correct location. Tried get the rendered bounds of the path and calculating it from that, but same thing... +/- 1 issues. Also tried setting everything to absolute mode and setting the rectangles identically, nope... Maybe the LinearGradientBrush only *appears* to be working and is hiding the +/- 1 issues with the gradiented color switch.
|
|
|
|
|
I have a DataGrid with a Date column. I need to show the date as:
"Wed, 12 Dec" - Short day, day number, and short month
I've tried a bunch of options, including these[^], but I can't get it to work.
What's the correct XAML for this?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
|
Technically accurate but practically useless.
I didn't ask for the ISO standards.
What's the XAML?? I tried a bunch and it won't compile.
If it's not broken, fix it until it is
|
|
|
|
|
Kevin Marois wrote: I tried a bunch and it won't compile. Interesting, but you cannot expect people to guess what that bunch comprises.
|
|
|
|
|
Which is exactly why I provided the link to what I tried
If it's not broken, fix it until it is
|
|
|
|
|
PIEBALDconsult is completely right. You need to change MM/dd/yyyy to custom format. Try!
|
|
|
|
|
I HAVE been trying. I can't get it... Which is why I ask what the syntax was.
If it's not broken, fix it until it is
|
|
|
|
|
|
I knocked together a quick sample to test. As long as you're binding to a DateTime field, you can use syntax like this:
<DataGridTextColumn Binding="{Binding CurrentTime, StringFormat='{}{0:ddd, dd MMM}'}" Header="CurrentTime"/>
|
|
|
|
|
Thank you Pete. That did it!
I think I was missing the leading braces.
If it's not broken, fix it until it is
|
|
|
|
|
You're welcome. Yeah, that would cause issues.
|
|
|
|
|
Ya I was pulling some hair out before I finally posted here.
Thanks again
If it's not broken, fix it until it is
|
|
|
|
|
I created a UserControl with an event:
public partial class AssignedEmployeesControl : _BaseUserControl
{
public event RoutedEventHandler AssignmentRemoved;
}
then I add the control to a data grid in the code behind:
private void addAssignedEmployeesColumn()
{
DataGridTemplateColumn employeesColumn = new DataGridTemplateColumn();
employeesColumn.Header = "Assigned Employees";
employeesColumn.Width = new DataGridLength(1, DataGridLengthUnitType.Star); ;
FrameworkElementFactory factory = new FrameworkElementFactory(typeof(AssignedEmployeesControl));
factory.SetValue(AssignedEmployeesControl.EngineRefProperty, EngineRef);
factory.SetValue(AssignedEmployeesControl.AssignmentShiftProperty, new Binding("Shift"));
factory.AddHandler(AssignedEmployeesControl.AssignmentRemoved, new RoutedEventHandler(AssignmentRemoved));
DataTemplate cellTemplate = new DataTemplate();
cellTemplate.VisualTree = factory;
employeesColumn.CellTemplate = cellTemplate;
assignmentsGrid.Columns.Add(employeesColumn);
}
I want to handle the event as follows
private void AssignmentRemoved(object sender, RoutedEventArgs e)
{
}
The AddHandler line doesn't compile. I get
Argument 1: cannot convert from 'System.Windows.RoutedEventHandler' to 'System.Windows.RoutedEvent'
The best overloaded method match for 'System.Windows.FrameworkElementFactory.AddHandler(System.Windows.RoutedEvent, System.Delegate)' has some invalid arguments
The event 'FMG.UI.WPF.Shared.Views.Controls.AssignedEmployeesControl.AssignmentRemoved' can only appear on the left hand side of += or -= (except when used from within the type 'FMG.UI.WPF.Shared.Views.Controls.AssignedEmployeesControl')
I don't understand what's going on here. What's the right way to wire up my event?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
factory.AddHandler(AssignedEmployeesControl.AssignmentRemoved, new RoutedEventHandler(AssignmentRemoved));
Your first parameter should be the event name not the handler; AssignmentRemoved is the name of the handler in your code.
|
|
|
|
|
The name of the event in the control is AssignmentRemoved. I Named the handler the same.
If it's not broken, fix it until it is
|
|
|
|
|
Well the error message says it isn't. Why not change one of the names to make it less confusing and see what happens?
|
|
|
|