|
|
I have a problem with ValidationRules. Basically the data binding works, but the Validate-method of the ValidationRules never fire.
This is part of my XAML (ZoomDialogBox.xaml):
<StackPanel Grid.Column="0" Grid.Row="1" Orientation="Horizontal" VerticalAlignment="Center">
<Label>Factor:</Label>
<TextBox Name="FactorTextBox" Width="30" Margin="10,0,0,0">
<TextBox.Text>
<Binding Path="." UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<validators:ZoomFactorValidationRule MinZoomFactor="1" MaxZoomFactor="20" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
</StackPanel>
This is the property I am binding to, and this binding works (from ZoomDialogBox.cs):
public int ZoomFactor
{
get
{
return (int) this.DataContext;
}
set
{
this.DataContext = value;
}
}
As said, the binding works, but the ValidationRules is never applied. What am I doing wrong here?
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
|
I did try that earlier (and now again), and the result is the same. Validate() never fires!
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
Your ZoomFactor property should be turned into a property with a backing field.
There are many different ways for the TextBox to bind to the ZoomFactor property.
One way is in the constructor of the ZoomDialogBox.cs file, use this line of code
this.DataContext = this;
Then change the Path in the TextBox to ZoomFactor.
You should also look at the VS Output window to see any data binding errors when your application is running.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Yes, yes yes! Thank you. Now it works.
And thanks for the tip on the Output window, I did not know that databinding errors was shown there. That can be a great time-saver.
Once again, thanks for the help.
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
Glad you're up and running. Have a great day!
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Hi I have developed an ASP.Net application which uses silverlight.
This application works fine on my local PC.But when I uploaded it on the web server,it throws an exception saying
Silverlight error code: 2104 error type : InitializeError.
I have added the required(.xap application/x-silverlight-app,.xaml application/xaml+xml, .xbap application/x-ms-xbap ) MIME types to the IIS.
Still it is showing the same error.
Can anyone tell me how can I configure the webserver to support silverlight?
Thanks and regards
ARINDAM
|
|
|
|
|
I think the server doesn't support SilverLight.
Are u sure about it.
|
|
|
|
|
You can google how to configure MIME type for Silverlight. Let me know if you are still having this problem..
|
|
|
|
|
Hi!
I encounterd something weird!
Using the .net memory profiler, if i have a wpf button and hoover it, the number of undisposed instances increases dramatically.
Anyone here having the same problem?
Is it a problem or is it an error of the memory profiler?
BTW, neither the GC disposes these instances.
|
|
|
|
|
Can you post your XAML here. Just want to see exactly what you are doing.
Also, what version of Visual Studio are you using?
Any .NET services packs applied?
Which memory profiler?
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Simple XAML:
<Window x:Class="ButtonTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:command="clr-namespace:ButtonTest"
Title="Window1" Height="300" Width="300">
<Window.CommandBindings>
<CommandBinding
Command="{x:Static command:Stetics.uiCommand}"
Executed="CommandBinding_Executed"
CanExecute="CommandBinding_CanExecute"/>
</Window.CommandBindings>
<Grid>
<Button Height="50" Width="100" Command="{x:Static command:Stetics.uiCommand}"></Button>
</Grid>
</Window>
Code Behind:
namespace ButtonTest
{
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
{
}
private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
}
}
}
Software installed:
VS 2008 TS + SP1 (.NET 3.5 + Sp1)
.NET Memory Profiler 3.1 (http://memprofiler.com/[^]
Coderush EXPRESS 3.2
GhostDOC
Action:
Enter and Leave the Button.
Undisposed items after 60 sec. : 2.191 -> this number can get real high after a few minutes
Hope that helps.
|
|
|
|
|
This is just what we need to repro.
Can you also post the Command Code.
This way we are using the exact code you are.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Nothing special in here either:
using System.Windows.Input;
namespace ButtonTest
{
public static class Stetics
{
public static RoutedUICommand uiCommand = new RoutedUICommand();
}
}
|
|
|
|
|
Thank you. I just want to be sure we have the same code as you do.
I'll run the tests on Monday at work and get back to you.
Thank you for raising this important question.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Hi Karl,
Did you have a chance to look at this issue?
I also ran into the same issue with ObservableCollection<T> class.
Simple test code like this:
while (true)
{
ObservableCollection<int> collection = new ObservableCollection<int>();
}
Will generate one undisposed instance of ObservableCollection<int>.SimpleMonitor per observable collection created.
best regards,
Alex.
|
|
|
|
|
Hi,
I am developing customized WPF Tabcontrol. I need to customize the collection Editor which pops up for Items Collection. In the customized collection Editor, I need my customized 'myTabItem', also I need to hide the existing TabItem in the collection.
How can I get this behaviour.
Thanks in advance,
vinod
|
|
|
|
|
I don't think you can currently customize the designers for standard WPF controls.
You can extened the current TabControl and create a designers.
This Code Project article covers creating a designers for WPF controls.
http://www.codeproject.com/KB/WPF/XPlorerBar2.aspx[^]
modified 27-Feb-21 21:01pm.
|
|
|
|
|
|
I recently created a configurable image rotator using Silverlight 2 and C#. I want to post it on Code Project, but I feel like it needs a good solid code review first...and of course whatever changes fall out of that. I was hoping someone here might be willing to take the time to do this for me as I don't have any good Silverlight resources to call on.
My major area of concern is how slow the control is loading on the page. I'm doing a handful of asynchronous calls, building a list of image controls before rendering the parent control which contains them. I'm wondering if this is not the optimal way. Or maybe it just needs to be tweaked a little. Any comments would be truly appreciated. As soon as I feel I can share something worth sharing, I will get this up on Code Project in both C# and VB.
http://www.anothercodesite.com/Blog/[^]
Thank you,
Troy Johnson
|
|
|
|
|
Hey folks,
Just hoping for some advice with a big project I'm creating the styling for in WPF. I've created a ResourceDictionary which I link to all buttons etc via and ApplicationDefinition file, but this project has ten+ project files within the solution so is an ApplicationDefinition file in each project the best way to go about this?
Hope that makes sense!
Becky
|
|
|
|
|
Do you mean you have created a "typed style" like:
<Style TargetType="{x:Type Button}"><br />
...<br />
</Style>
A resource dictionary does not target types the styles contained within the resource dictionaries do.
Project files also don't really make any difference. If these project files are all part of the same solution a style loaded into the application will apply to any buttons in the UI irrespective of the project (dll) they reside in.
Is this a composite application by any chance?
|
|
|
|
|
Sorry yes a typed style within a Resource Dictionary. My problem is that I understand putting the ResourceDictionary reference into an App.xaml file which means that then all those UIs within that project will then be affected by the style, but I need this to affect the entire solution (over multiple projects). Is there a way to create an App.xaml-like file that is solution-wide?
Thanks for the reply!
Becky
|
|
|
|
|
The short glib answer is no!
A single application (that loads the app.xaml and consequently the linked resource dictionaries) can be made up of multiple projects. A project in a solution is simply a dll. When a project is built it outputs a single dll or exe file. So one or more of those project may well be in the same application.
Would it be fair to assume that the solution your talking about actually contains multiple applications?
One thing you could do is move all of your styles into a single dll you can then put something like this in your app.xaml file in order to load all of the resource dictionaries and styles into each of the applications your trying to style ...
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/YourCompanyName.WPF.Styles;component/YourResourceDictionary.xaml" />
</ResourceDictionary.MergedDictionaries>
This xaml file will of course contain one or more resource dictionaries. You could separate them into control for instance so you might have button.xaml, combobox.xaml etc ...
Then you just need to include a reference to this style project in each of the applications in the solution and you should be good to go.
Let me know if this is unclear and I'll try to put a demo together ...
|
|
|
|