|
This is the answer I would have given. Well done and my 5.
|
|
|
|
|
Ok, I'm still stuck on this. My RelayCommand class (That I got from Josh Smith) defines
public event EventHandler CanExecuteChanged;
public void RaiseCanExecuteChanged()
{
var handler = CanExecuteChanged;
if (handler != null)
{
handler(this, EventArgs.Empty);
}
}
The event declaration appears in intellisense, but not the RaiseCanExecuteChanged. Maybe this is why I'm having the problem.
I wrote a quick sample app[^] that demonstrates what is happening.
Thing is, I'v been using this RelayCommand forever, and now all of a sudden I start having this problem.
[UPDATE]
I replaced my class with this[^] and now it works. It seems I was using a Func instead of a Predicate. I know for sure this was working code at some point.
If it's not broken, fix it until it is
modified 31-Jul-12 17:09pm.
|
|
|
|
|
Yes you are right. Get my +5.
http://www.exploresilverlight.com
Cheers!
Vinod
|
|
|
|
|
I have a very basic query. Let's say we have a Color1, and I need Color2 to be
Color.FromRgb (Math.Min(Color1.R+10,255), Math.Min(Color1.G+10,255), Math.Min(Color1.B+10,255));
But I am not able to do this simple thing. Basically, I've got stuck with integer and byte conversion. Please suggest in following code-
private Color GetNewColor(Color colorParameter)
{
Color newColor;
return newColor;
}
|
|
|
|
|
What exactly is going wrong? Are you getting an exception or a compiler error or is it just not doing what you expect?
One possible issue I can see is an overflow of the colour component. For example, with a byte , if you add 10 to 255 you'll actually end up with 9, and Math.Min won't work as you expect. You can catch this problem by surrounding the code with a checked statement, which will cause the runtime to throw on an overflow.
The quickest solution to this would be to cast the byte to an int first, do the addition, and cast the result back to a byte (once you're certain it'll fit).
|
|
|
|
|
Thanks for the reply!
Problem was with casting only. I've sorted that out now. Trivial, but just thought of sharing it:
byte r = Convert.ToByte(Math.Min(255, Color1.R + 10));
byte g = Convert.ToByte(Math.Min(255, Color1.G + 10));
byte b = Convert.ToByte(Math.Min(255, Color1.B + 10));
return Color.FromRgb(r, g, b);
|
|
|
|
|
In Silverlight you can do this:
private Color GetNewColor(Color colorParameter)
{
Color newColor;
Color newcolor = Color.FromArgb(0, 255, 10, 10);
return newColor;
}
You can read this[^] too.
Regards
Christian Amado
MCITP | MCTS | MOS | MTA
Olimpia ☆ ★★★
Please mark as answer, if it helps.
|
|
|
|
|
Hi,
Below is my requirement:
I need to display various data in my dashboard report. the data will be fetched from SQL server 2005 DB. the data will be like:
1. sales data: buy, sell, value, sales team code & name
2. client asset data: product, asset value, sales team code & name, client code & name
3. revenue data: brokerage amount, product and client code & name
need to send all the above data to silverlight page through single WCF service. what is the best method to achieve the requirement.
any advise would be very helpful and i am new to wcf and silverlight.
thanks in advance
Durga Charan K
|
|
|
|
|
Use a placeholder class that contains all these as getter-setter properties.
You can share this property class (or model) between the server and client OR have two copies and populate them both on server and client. That choice is left to you.
|
|
|
|
|
I have a Silverlight Business Application, three project on it:
1. SLApp (Silverlight Application).
2. SLDataServices (ADO.NET Entity Framework, Domain Service, Metadata, Extensions for metadata).
3. SLWeb (ASp.NET WebSite with ASP.NET Membership enabled and working).
When I run the project a Login Page appears, you type user and pass. After that you logged on, so the Silverlight app loads (I pass user & pass parameter) and login in silverlight app too.
When the Ribbon Menu loads (via DomainDataSource) I see the error on the RequiredAuthentication Atributte on my DomainService in SLDataServices project. When I breakpointed on this line of code I can see that I have a cookie empty and the ServiceContext setted to null.
Using an Oracle Database.
How can I obtain the user authenticated on my DomainService?
Thanks in advance.
Christian Amado
MCITP | MCTS | MOS | MTA
Olimpia ☆ ★★★
Please mark as answer, if it helps.
|
|
|
|
|
I need to get color value, when user clicks anywhere (inside or ourside of the main window). Possible? If yes -
1) How do I get pixel value of outside of window? How can I check the MouseDown/Up in this case?
2) What should be the approach to get color value of a pixel, which is outside of the main window?
|
|
|
|
|
I add manipulation (ManipulationStarting, ManipulationDelta events) to a WPF application. In the main window there is a ListBox for which, before adding manipulation, "tap" events were promoted to mouse events, while now that the Manipulation processor capture the touch device they are no longer promoted. This behavior is well explained by JoshB in this article
http://nui.joshland.org/2010/04/why-wont-wpf-controls-work-with-touch.html[^]
My question is: how can I get the ListBox selected item when the user "tap" upon a ListBoxItem? Have I to use Surface 2.0 SDK controls (SurfaceListBox)?
|
|
|
|
|
How get all Office version installed using SilverLight?
Thankyou!
modified 23-Jul-12 2:40am.
|
|
|
|
|
Silverlight is an add on to your browser, you can't "install" office in it!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If you want to know what version of Office have your client installed you can try this:
Code Project Article
Regards
Christian Amado
MCITP | MCTS | MOS | MTA
DCE 0★ 1★ 2★ 3★ 4★ 5★
Bronze level MVA
Olimpia ☆ ★★★
|
|
|
|
|
Hi Christian.
This Topic get only one version.
I want get another version.
Thank bro!
|
|
|
|
|
The exact code of this only gets one version, however looking through the registry it looks like you can figure that out, consider "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\" which contains sub keys for each installed version of office.
If or how registry access works in silverlight i'm not sure, but if the only problem with the provided sample is just one version being returned then you can get that info from the registry.
|
|
|
|
|
Let me clarify that a bit more. I'm currently binding my buttons to be enabled if my Stored settings bool value is true. Meaning in this case dbOpen. This is true if my database is loaded, false if it's closed. Now I have certain buttons I want to be enabled when this is true so I have the xml code like this:
IsEnabled="{Binding Source={x:Static prop:Settings.Default}, Path=dbOpen, Mode=TwoWay}"
Now I want certain buttons to be able to be disabled when the dbOpen is true so how do I flip the value in the xml statement? in c# it would be like :
If (Settings.Default.dbOpen) to check if it's not true you would If(!Settings.Default.dbopen)
modified 24-Jul-12 11:04am.
|
|
|
|
|
I have a set of NOT converters!
public class BooleanNotConverter : IValueConverter
{
object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool bReturn = false;
int iValue;
try
{
if (Int32.TryParse(value.ToString(), out iValue))
{
bReturn = iValue != 0;
}
else
{
Boolean.TryParse(value.ToString(), out bReturn);
}
}
catch { bReturn = false; }
return !bReturn;
}
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
int iReturn = 0;
bool bReturn = false;
Boolean.TryParse(value.ToString(), out bReturn);
if (!bReturn)
{ iReturn = -1; }
return iReturn;
}
}
And the xaml
IsEnabled="{Binding IsLocked,Converter={StaticResource BooleanNotConverter}}"
And the App.xaml resource
<!--Converter Resource-->
<ResourceDictionary>
<converter:BooleanNotConverter x:Key="BooleanNotConverter"/>
</ResourceDictionary>
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
For some reason it's just not working as expected. The open database button is enabled by default this allows it to open a database. Once I load the database I set the dbOpen property to True which if this is working properly should disable the button since it inverts the True to a false. But it's not. The Button is enabled the entire time. Now I know dbOpen is true because my code to load the database will only run if(!System.Properties.Default.dbOpen), and while the button does not disable the code to open the database does not fire when clicked.
|
|
|
|
|
I know this is a really dumb suggestion but try it any way, presuming your converter is working as expected and have tested it on some other control, try changing your button from a Command"" to Click. I have found (twice) that for some reason the IsEnabled event is ignored if there is a command on the button (I have no idea why and don't have the motivation to chase it down as it happens only rarely).
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I tried that and sadly it didn't change anything. One thing is possible I'm using the Actipro WPF Ribbon and it's the QAT open button, and backstage open buttons I'm trying to disable using this method. I don't know if by chance it's an issue with their control or not.
I can tell you that I have had success using a regular boolean converter to enable/disable the buttons on their ribbon, just not this inverted boolean converter.
|
|
|
|
|
Got it working!
Was a really stupid mistake I forgot to tell it the source of where my variable to tie it too was. Since it's a Property stored by the project I had to do the IsEnabled command as so:
IsEnabled="{Binding Source={x:Static prop:Settings.Default}, Path=dbOpen, Converter={StaticResource booleanNotConverter}}"
|
|
|
|
|
While your code works just fine... a more generic solution is to use a map converter. That way you don't need to keep writing these one-off converters that basically map one value to another. It's all in one converter and you just define the mapping in XAML.
|
|
|
|
|
Well don't just drop it as a comment, link please. I have about 8 converters so there is very limited rewriting.
Never underestimate the power of human stupidity
RAH
|
|
|
|