Extension Method
[code:c#]
internal static class InteropExtensions
{
public static bool? ShowDialog(this System.Windows.Window win, IntPtr handle)
{
WindowInteropHelper helper = new WindowInteropHelper(win);
helper.Owner = handle;
return win.ShowDialog();
}
}
[/code]
Usage
[code:c#]
var win = new WpfWindow();
win.ShowDalog(windowsFormOwnerHandle);
[/code]
I've been playing with a workflow service hosted here /PSService/PSService.svc
Feel free to give it a bash [August 2012, removed]) Endpoint is using basic http binding.
Tonight I whipped a Sql Server Compact Database out of another little app I have lying around so I could sit it behind the webservice persist data.
But
To my horror it doesn't work..
I get the following exception " sql compact is not intended for asp.net development"
I can imagine why I guess.. bit what a pity.. it's not allowed..
[August 2012: It is allowed, just needs a setting]
Addin splitters to the WPF grid couldn't be easier.
Veritcal
<GridSplitter />
Horizontal
<GridSplitter Height="3"
ResizeDirection="Rows" Background="Transparent"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" Grid.Row="1" />
Ever have a control on a window and want to be able to receive button clicks from this child control?
More than one I've done this the hard way, but now.....
[code:c#]
public VariablesWindow()
{
this.InitializeComponent();
variables.AddHandler(Button.ClickEvent, new RoutedEventHandler(HandleChildClick));
}
private void HandleChildClick(object sender, RoutedEventArgs args)
{
Button senderButton = args.OriginalSource as Button;
if (senderButton != null && senderButton.Content != null)
{
string buttonText = senderButton.Content as string;
if (buttonText == "_Cancel")
{
this.DialogResult = false;
Close();
}
else if (buttonText == "_OK")
{
this.DialogResult = true;
Close();
}
}
}
[/code]
Recently I used PInvoke to check if the SHIFT key was pressed while i was doing a drag operation......
what I should have done then and have done now is
[code:c#]
if((Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.None)
Trace.WriteLine("Shift is pressed");
[/code]
Recently I've been working with a 3rd party diagramming library written in windows forms. It's been great and it's pretty fast in building 80% of the application I'm working on.
[Update August 2012: I never got around to doing much with the diagramming library. I opted instead to re-host the visual studio workflow designer for my needs, why I actually considered writing it is beyond me, I’m a campaigner for bolting existing solutions together rather than re-inventing the wheel ]
Today I needed to control the enabled property of a button "Remove Item" on my form depending on weather there was a selected item in a Listbox.
Here's how
[code:c#]
<Button Content="Remove" Click="OnRemoveTranstion">
<Button.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding ="{Binding ElementName=listDetails, Path=SelectedIndex}" Value="-1">
<Setter Property="Button.IsEnabled" Value="false"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
[/code]
If you've created a new WPF project in VS2008 and then you try to design your UX in Expression Blend 3 you'll find that you get xaml view only.
What is required is to add
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
to the project file.
With .NET 1.1 when we receive a UTC DateTime in a SOAP response from a Webservice it used to get converted to Local time.
With .NET 2.0 when we receive a UTC DateTime in a SOAP response it stays in UTC.
If you need it in local time make sure to call .ToLocalTime()
** Edit: P.s. Have a look at this neat class in the framework XmlConvert
Announced at PDC this week
http://www.microsoft.com/downloads/details.aspx?FamilyID=6806e466-dd25-482b-a9b3-3f93d2599699&displaylang=en
Finally a version of blend that will open vs2010 projects (and of course handle Wpf4 and Silverlight 4)
It will run side by side with Blend 3
Enjoy 