|
I am wondering if anyone can point me to some code (or DLL) to build a native OpenFileDialog and FolderBrowserDialog in wpf / xaml, rather than using the System.Windows.Forms controls?
We have now replaced the Forms MessageBox with a native WPF taskdialog, which looks much better and behaves more consistently. I would like to do the same for OpenFileDialog and FolderBrowserDialog.
Thanks,
Tim
|
|
|
|
|
WPF has a OpenFileDialog class in the Microsoft.Win32 namespace.
For Folder Browser dialog, see my blog[^]
I thought Pete O'Hanlon was working on a WPF version at one time
It's definitely a project to make a WPF version to replace the OS
dialogs...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have been working on one - it's something that I keep coming back to when I have some free time. It's a hell of a complex beast though, as I'm trying to make it completely skinnable.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I've only just been able to get back to this question - sorry for the long delay in responding. I guess it looks like this is a complex issue - I'll keep wrapping the System.Windows.Forms controls for the time being, and look out for further developments on this question. Hopefully Microsoft might build something into a future version...
Thanks,
Tim
|
|
|
|
|
I've got a 3rd party control:
class Foo : SomeWPFControl, INotifyPropertyChanged
{
public DateTime Start { get; }
public event PropertyChangedEventHandler PropertyChanged;
}
I slap this control on my view. Then I code up a little ViewModel. All is good.
I need to do work in my ViewModel when the control's Start property changes. How do you recommend doing this?
Attempt #1: I tried creating a DateTime property in my view model, then binding the control's .Start property to my property in the ViewModel, but that didn't work because "Start is a read-only property". Fail.
Attempt #2: I can listen to control.PropertyChanged inside my view, and when it fires, call some function on my ViewModel. But that doesn't seem very MVVMish. Fail?
Religiously blogging on the intarwebs since the early 21st century: Kineti L'Tziyon
Judah Himango
|
|
|
|
|
Have you tried, in the binding, specifying "Mode=OneWayToSource"?
If that doesn't work, then if I'm interpreting this correctly, #2 is probably the way to go.
|
|
|
|
|
Yeah, I still get a compiler error when specifying Mode = OneWayToSource.
Religiously blogging on the intarwebs since the early 21st century: Kineti L'Tziyon
Judah Himango
|
|
|
|
|
Strange... Might not be set up properly as a DependencyProperty. #2 might be your only option, unfortunately.
|
|
|
|
|
There is a DependencyProperty on the class:
public Foo
{
public static DependencyProperty StartDateProperty;
public DateTime StartDate
{
get { ... }
}
}
The only way to change the StartDate is by clicking a button in the 3rd party control.
Religiously blogging on the intarwebs since the early 21st century: Kineti L'Tziyon
Judah Himango
|
|
|
|
|
Hmm, strange way of setting it up...
I mean, you could bind another control to that value, but you can't bind the "StartDate" to a CLR object.
Yeah, I don't see a solution here other than hooking PropertyChanged.
|
|
|
|
|
Alright, well that's a legitimate answer, too. Thanks.
I'm mostly a newb when it comes to WPF, and definitely a newb when it comes to MVVM. I just wanted to be sure I wasn't doing things improperly. If this is the only way to make this work, alrighty.
Religiously blogging on the intarwebs since the early 21st century: Kineti L'Tziyon
Judah Himango
|
|
|
|
|
Yeah, it's not ideal, but you do what you have to do, right?
|
|
|
|
|
Is the Start property in the control readonly? What is the mechanism for updating this property?
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
The Start property is a readonly .NET property:
public DateTime Start
{
get { ... }
}
There is a static DependencyProperty behind the scenes:
public class Foo
{
public static DependencyProperty StartProperty;
}
Pete O'Hanlon wrote: What is the mechanism for updating this property?
If the user clicks a button in the 3rd party control, the .Start will change.
Religiously blogging on the intarwebs since the early 21st century: Kineti L'Tziyon
Judah Himango
modified on Wednesday, December 9, 2009 5:38 PM
|
|
|
|
|
Hello,
Fairly new to WPF so hope this isn't going to be a case of failing to RTFM but I just can't see what has gone wrong.
I am modifying an existing user control to show slightly different data in a list depending on a setting on the control. I have registered the dependency property, added a get;set to use it else where in code and it comes up in the Intellisense in the XAML file. However it is not set to the value I've set it to in the XAML when it is check in the controls constructor.
Here is the relevant bits of the user control:
public partial class StationGroupControl : UserControl
{
public StationGroupControl()
{
try
{
if (ShowAggregates != true)
...
public static DependencyProperty ShowAggregatesProperty =
DependencyProperty.Register("ShowAggregates",
typeof(Boolean),
typeof(StationGroupControl),
new FrameworkPropertyMetadata(false));
public Boolean ShowAggregates
{
get
{
return (Boolean)GetValue(ShowAggregatesProperty);
}
set
{
SetValue(ShowAggregatesProperty, value);
}
}
And the XAML:
<ResearchCtrl:StationGroupControl Name="MultStation" HorizontalAlignment="Left" Margin="-122,0,0,0" Validation.Error="Ctrl_Error" ShowAggregates="True"></ResearchCtrl:StationGroupControl>
Frustratingly this seemed to be working and I then refactored the code down to smaller chunks and it inexplicably stoppped working. It has me doubting if it was ever working properly.
Is there some issue with using a boolean? Something else I need to do? Any way of debugging what is actually happening?
I'm pushed for time on this so any suggestion gratefully received.
Robert.
|
|
|
|
|
You're testing the value in the constructor, but it's not being set until AFTER.
The XAML is going to first create the object, THEN start setting properties... So basically what's happening is:
1) Object created
2) Constructor fires, checking ShowAggregates value
3) XAML parser sets the Name property
4) XAML parser sets the HorizontalAlignment property
...
7) XAML parser sets ShowAggregates to true
EDIT: Oh, should have added... The solution is to hook the Initialized event, or override OnInitialized, and do the check there.
|
|
|
|
|
Thanks, as suspected if I'd read the "manual" more closely I'd have spotted that eventually, if I wasn't mildly panicking I probably would have.
Thanks again Ian!
|
|
|
|
|
Hello again,
I tried moving the code to the Initialized event but it still wasn't set. I've now moved to the Loaded event and it is there so that's where I've left it for the moment. Let me know if you think this might cause a problem.
Thanks,
Robert.
|
|
|
|
|
|
Hi,
Is there a way in xaml/wpf to freeze first item in listbox from scrolling?
Thanks
|
|
|
|
|
Here is the scenario:
1. Open Visual Studio 2008, create new project...
2. Select WPF Custom Control Library as the project type
3 Open the Generic.xaml resource dictionary located in the Themes folder
4. Add a simple brush such as:
<SolidColorBrush x:Key="BackgroundBrush" Color="Yellow"/>
5. Change the Background property of the nested Borer Control from
Background="{TemplateBinding Background}"
to
Background="{DynamicResource BackgroundBrush}"
Now when you compile and use this control in any project, the background will NOT be yellow. BUT, if you change the background property to be a StaticResource as such
Background="{StaticResource BackgroundBrush}"
...it will work. Why is this? Why does StaticResource work but not DynamicResource???
|
|
|
|
|
Hi,
I am working with a Silver light application with WCF service. In this I have a session variable names "UserId" which will be created in user login.aspx page. Now I need to access this current login UserId into my WCF service.
or
I need to access this UserId sesssion variable in the silver light page and then pass it to WCF service as parameter.
If any one have any idea ti implement any one of the above please reply me.
Thanks in advance.
|
|
|
|
|
|
I have another issue with the WPF Ribbon control when i have two buttons on the bottom of the Application menu button. When i'm running my app and i click on a button on one of my tabs, it pops up with a user dialog for the user to choose then close. The issue i'm having is when the user clicks on any of the buttons in the dialog and then closes it, the two buttons i have in the Application menu button are disabled for some reason until the user clicks on the menu bar again. Why is that? Is this a known issue or just a quirk in WPF Ribbon? Thanks in advance!
|
|
|
|
|
how do i disable the mouse scroll in the WPF ribbon bar?
i'm trying to disable this because of the tabs that i have in my ribbon bar shouldn't be accessed until they are properly called on. This causes issues when the user is able to scroll through the tabs
Any ideas or advice would be much appreciated! 
|
|
|
|