|
Hi there,
I am new to WPF, I have just learned how to customize the progressbar by using a control template. I made it so that the indicator part of the progressbar has a gradient effect.
Now i actually want it to fade in as the value increase, I know that I can make use of the triggers on the value of the progress bar and set the opacity of the indicator, but i am not sure how that can be done.
Also, I would like to have a box following the top of the indicator to indicate the value of the progessbar, my approach is to create another column from the grid, place a textbox inside, and then again using trigger change the coordinates of the box. But i am not sure how i can convert the value of the progressbar to the coordinates of the textbox.
here is what i have so far
<UserControl
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"
mc:Ignorable="d"
x:Class="IceControls.CivicProgressbar"
x:Name="UserControl" d:DesignHeight="492" Width="50">
<UserControl.Resources>
<ControlTemplate x:Key="templateThermometer"
TargetType="{x:Type ProgressBar}">
<ControlTemplate.Resources>
<LinearGradientBrush x:Key="brushStem"
StartPoint="0 0" EndPoint="7 0">
<LinearGradientBrush.Transform>
<RotateTransform Angle="90"></RotateTransform>
</LinearGradientBrush.Transform>
<GradientStop Offset="0" Color="white" />
<GradientStop Offset="1" Color="transparent" />
</LinearGradientBrush>
</ControlTemplate.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100*" />
</Grid.ColumnDefinitions>
<Border Grid.Column="0" BorderBrush="Gray"
BorderThickness="1 1 1 1"
CornerRadius="6 6 0 0" >
<Decorator Name="PART_Track">
<Border Name="PART_Indicator"
CornerRadius="6 6 0 0"
VerticalAlignment="Bottom"
Background="{StaticResource brushStem}" />
</Decorator>
</Border>
</Grid>
</Grid>
</ControlTemplate>
</UserControl.Resources>
<StackPanel>
<ProgressBar Template="{StaticResource templateThermometer}"
Orientation="Vertical" Minimum="0" Maximum="100"
Width="auto" Height="350" Margin="0,0,0,0"
Value="{Binding ElementName=scroll,Path=Value}" />
<ScrollBar x:Name="scroll" Orientation="vertical"
Minimum="0" Maximum="100"
SmallChange="1" LargeChange="10"
Margin="16.5,0" Height="120.5" />
</StackPanel>
</UserControl>
|
|
|
|
|
I've created a user-control for WPF using C#. Control has a warning MessageBox, which I want to appear only if it is being used by some EXE, but it should not appear while developing. So basically, it should appear the way it appears for unregistered controls. Currently it is appearing in both development/runtime. How can I do that?
|
|
|
|
|
I use the following simple test:
_designMode = DesignerProperties.GetIsInDesignMode(new Button())
|| Application.Current == null
|| Application.Current.GetType() == typeof(Application);
if (!_designMode)
{
var designMode = DesignerProperties.IsInDesignModeProperty;
_designMode = (bool)DependencyPropertyDescriptor.FromProperty(designMode, typeof(FrameworkElement)).Metadata.DefaultValue;
}
"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
|
|
|
|
|
That works, thanks!
|
|
|
|
|
You're welcome.
"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
|
|
|
|
|
Hi,
After installing Silverlight Tools I have Silverlight Application template is missing. The only templates are present Silverlight Class Library, Silverlight Navigation Application and Silverlight Unit Test Application. I already tried to uninstal and reinstall without any success, template still missing. Any idea how to fix it without rebuilding my PC?
Thanks,
Alex
|
|
|
|
|
Which version of Visual Studio are you using?
If it is VS 2008, make sure you have SP1 installed. Try reinstalling the SL toolkit.
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
It's VS 2008 with SP1 installed, and I already tried twice to reinstall
|
|
|
|
|
Open the visual studio command prompt and run this - devenv /ResetSettings.
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Done it, this thing anly copy from \ProjectTemplateCash and if Cash wrong too it will not fix anything
|
|
|
|
|
Hi,
Apologies this is a general question, and I am looking for a ball-park answer.
I have a little experience in MATLAB, a little experience in C, good experience in SQL, and no experience with C#, .xaml, or WPF.
I have a project at work to develop an application in C# WPF that will need to examine and modify values in a SQL database. A fair part of this project involves me learning the necessary skills.
So 2 questions:
1) How long would you expect me to need to spend to get my skills up to scratch?
2) What resources would you recommend are best? In your experience is there significant benefit to attending a course on these subjects to speed learning up?
So far I have read (and done examples from) a C# .NET in 24 hours book, and feel like I have only a basic understanding.
Cheers
Tim
|
|
|
|
|
|
Thanks for the speedy response, had a brief look and the links are very useful.
Afraid I've not even done any real OOP programming before. Messed about with some VBA but that is about as close as it gets.
Also the amount of time I'm likely to get for this at work is probably around 1 day a week, plus some time outside of work if I'm able. With this in mind do you still think 2-3 months, or would 2-3 months be the estimate for studying this stuff full time?
Cheers
Tim
|
|
|
|
|
Even 2-3 months is not enough to learn everything of C# and WPF. It is all depend opon your technichal skill or we can say your grasping power.
But I would suggest before going to any implement any module try to filter information from google or codeproject that what is the best wayt to implement as your requirement.
Keep posting with proper/requirement information on this forum so here experts can suggest and reply you quickly.
If you are stucking somewhere then feel free to post here, we are happy to help you.
Keep studying to grasp basic/core concept of C# including his 3.5/4.0 feature as well for WPF. I am sure when you are going to implement it you will difenitly start thinking in your classic way as you have experience. But again I am saying try to find out what is the best way to implement it.
Thanks for your patience!
Parwej Ahamad
ahamad.parwej@gmail.com
|
|
|
|
|
Tim - learning WPF is a huge undertaking. I was an experienced ASP.NET and WinForms developer long before I looked at WPF, and it took me well over a year before it properly clicked into place. I think 2-3 months, given your limited experience, is wildly overoptimistic.
"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
|
|
|
|
|
Hey Pete,
I have been helping out with interviews for my employer recently. I'm moving on to a new organisation in a few weeks so have been interviewing for my replacement.
One chap I interviewed a few weeks ago said that he didn't have any WPF experience but could pick it up in a day ... the level of arrogance was unprecedented as far as I'm concerned. Needless to say we hired the other guy.
Unbelieveable.
|
|
|
|
|
Jammer wrote: he didn't have any WPF experience but could pick it up in a day
I assume he meant he'd be able to spell it out in the right order in that time. I knew a contractor who told me he'd blag it in an interview and get a job doing WPF. He was mightily pissed with me when I threw questions at him like what constraints are in place if you want to use a dependency property, why are DPs different to properties, how do you retemplate a control, and the like? This level of arrogance just serves to piss me off; it took me a very very long time to get to grips with WPF, and I'm lucky enough to be able to have conversations with the likes of Josh, Karl, Sacha, Dan Vaughan and the likes.
"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
|
|
|
|
|
Couldn't agree more Pete, I was in disbelief hearing those words!
|
|
|
|
|
I agree with Pete completely. I started my forays into OO and WPF at the same time, Jan 2008. I still know jack and believe me I've put a LOT more time in than you have available.
Do you have access to a full blown Visual Studio or just C# Express?
This is a HUGE undertaking on your part and do not underestimate what you are taking on. Come back with some more information and then we can come up with a plan of attack.
Cheers,
|
|
|
|
|
I've got access to a full blown Visual Studio 2008 at work, along with SQL server 2008.
The aim, and approach from my manager (he's not a programmer) is to learn just as much as necessary to be able to do a reasonable job designing a new application. It's an internal application that is replacing a couple of horrific Access tools, and would only be used by less than 20 people in the UK, AUS, and USA.
The use of the tool is for Product Managers to be able to submit requests to load details of new products onto our CRM system. This will consist of a SQL Server back-end to hold details of the request. I believe there will be about 7 tables needed for details of the product and linked attributes, price lists, etc, and maybe one or 2 more for Lists of Values.
Some required features include:
- Multiple datagrids that must filter based on which record is selected above (I managed to do this but to be honest don't fully understand how it works)
- Combobox fields in the datagrid that are linked to the CRM system to retrieve available values
- Fields in datagrid to be read only depending on other database values
- Automatic validation of requests upon submission, returning list of problems found
- Hyperlinks in datagrids to take user to specified request
- Routed events will be needed to control elements of the UI (I've been using
The other half of the tool is for use by IS to actually load the products to the CRM. This will be done using comms. Due to the complexity of Siebel CRM whenever data is uploaded it is always via comms instead of directly with update statements. This is another thing I will have to learn to write.
The main difficulty I have is that when I find solutions I often find that I don't have the base level of understanding so can find it extremely difficult to follow people's suggestions! Also worth mentioning that one of the guys in development who has worked with WPF (though not with datagrids) has a couple of hours available per week to help me out with random questions, which can be very helpful.
My general tactic so far has been partly to focus on getting specific proof of concepts up and running that I know I'll need, and partly to slog through books to get an understanding of some of the more fundamental knowledge that generally helps when writing C#/.xaml.
I'm trying to arrange with the guy in dev to actually go through some practicals for some of this stuff, so I can hound him with questions and try to get a bit of a better understanding.
Any suggestions for how you guys picked this stuff up would be really helpful. Currently I feel like I'm a bit out on a limb being the first person to learn any C# in IS!
Cheers
Tim
|
|
|
|
|
A good thing to do right now would be to buy a decent book. I had C# 3.0 in a Nutshell and WPF Unleashed practically stapled to my person for a good year and a half. The C# 3.0 book is really great as it is very informative and concise in it's explanations and whenever digging into something it gradually introduces the complexities rather that starting with them.
Sounds to me like you need to explore a number of big topics to get this app completed. Stuff like N-Teir/SOA architecture, WCF (Web services), LINQ or the Entity Framework for data access layer (interaction with SQL Server) as well as C# / WPF. This is a lot to go for at once.
I think it might be a good idea to start with smaller portions of stuff to begin with. Have you used Test Driven.NET? Since you have the full blown VS 2008 you can use plugins.
Go and grab a copy of http://www.testdriven.net/[^] and install it. Then create a basic class library and write some unit tests. This will provide you a really nice environment to learn in. TTD.NET will allow you to write a unit test in C# and simply right click it to run the code (with or without the debugger attached). I personally love this combination as it's a really fast way to play with code.
This will also get you into a good habit of writing tests to either prove your code works or drive the development process itself.
The datagrid stuff you talk about doing is fairly straight forward but I woould cover off some simpler WPF data template / styles stuff before leaping into that just yet.
|
|
|
|
|
Hello all,
I'm fairly new to Silverlight and MVVM and I'm struggling with the correct way of doing the simple task of changing the top level silverlight view. Using Silverlight 4 commanding I am binding a command on my view model to a login button on my main form and then calling an authentication service to ensure the credentials are valid, this is working and I can authenticate the user. What I am struggling with is the best way of closing the login screen and displaying another screen when I get a successful response from my service. From what I understand you cannot hook a callback event in the view to a command object and I should also be trying to avoid having any code behind in the view so where do I control the opening of a new view? Obviously, my ViewModel should know nothing about the view so I can't do it there, can I?
The way I was going to approach it is still use the button bound to a command on the view model but use a bit of code in the view to hook an event to the view model which is fired when I get the successful login from the service. The event hooked up in the view would then control switching the views but from the examples I have looked at I am not convinced this is the best way forward.
Am I missing something obvious or looking at the problem in completely the wrong way?
I'm hopeful this question will have a straight forward answer but after hours of browing examples on the web I'm still none the wiser as to the correct approach.
|
|
|
|
|
DoctorMick wrote: Obviously, my ViewModel should know nothing about the view so I can't do it there, can I?
There could be a few ways to handle this.
An easy approach would be to use the navigational framework. But this does not provide the decoupling you are talking about.
You cannot let your viewmodel know about the new view that you would want to launch, but you can let it know about the viewmodel for it. Create an instance of the view using the viewmodel. All this is based on the assumption that you are using the "viewmodel first" approach while implementing MVVM.
If you want to decouple a little more than that, use a common controller class that handles all view / view model creations - this way all your view model knows about is this common controller class - nothing else.
A fourth approach could be to use the EventAggregator pattern implemented by Microsoft Prism. Prism provides very high level of decoupling, but then there is a learning curve attached to the features it provides.
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Dear friends
i have an issue .. i am new to WPF,
my requirement is to (binding "custom property" for user control)
can some one point out my mistake?
User Control
-------------
<Grid >
<TextBlock Name="textBlock1" Height="28" VerticalAlignment="Top" Background="AliceBlue"/>
</Grid>
UserControl Code behind
--------------------------
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
public static readonly DependencyProperty coProperty = DependencyProperty.Register("CoType", typeof(int), typeof(UserControl1),
new UIPropertyMetadata(string.Empty, new PropertyChangedCallback(textChangedCallBack)));
int nType =0;
public int CoType
{
get {return nType;}
set {
nType =value;
textBlock1.Text = value.ToString();
}
}
static void textChangedCallBack(DependencyObject property,DependencyPropertyChangedEventArgs args)
{
UserControl1 searchTextBox = (UserControl1)property;
searchTextBox.CoType = (int)args.NewValue;
}
}
Main Form
-----------
<Grid>
<uc:UserControl1 CoType="{Binding CoTypeValue}"/>
</Grid>
Main Form Code behind is just InitializeComponent()
ViewModel
--------------
public int CoTypeValue
{
get { return nV; }
set {
if (value != nV)
{
nV = value;
OnPropertyChanged("CType");
}
}
}
The Error message i recive
Cannot create instance of 'UserControl1' defined in assembly 'WpfModelViewApplication2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation. Error at object 'System.Windows.Controls.Grid' in markup file
If i remove the Dependency property .. the error is not thrown .. but i want to binding for custom property.. and i not sure about the way i have implemented binding for custom property is the right way..
any help????
|
|
|
|
|
I have doubt with line:
public static readonly DependencyProperty coProperty = DependencyProperty.Register("CoType", typeof(int), typeof(UserControl1),
new UIPropertyMetadata(string.Empty, new PropertyChangedCallback(textChangedCallBack)));
As per my knowledge UIPropertyMetadata is mainly used for provide animation behavioure. I would suggest try with FrameworkPropertyMetaData for databinding purpose.
Just try on your side if still it is not working then I will look into that.
http://msdn.microsoft.com/en-us/library/ms751554.aspx[^]
Thanks for your patience!
Parwej Ahamad
ahamad.parwej@gmail.com
modified on Tuesday, March 30, 2010 9:53 AM
|
|
|
|