|
You could wrap your root element in a ScrollViewer element.
MArk
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Question was: how do I convert a hex string to a Media.Color, with the hope that .Net 3.5 was mature enough to provide a method.
I found the solution and wanted to delete the thread...
1) add a reference to System.Drawing
2) System.Drawing contains overloaded fromArgb() so that I don't have to bit-shuffle
EDIT: but this approach didn't work...
modified on Wednesday, September 16, 2009 8:43 PM
|
|
|
|
|
abiemann wrote: I don't want to split up the hex value into single bytes. I feel that I shouldn't have to.
Sometimes, a programmer has to actually program. Sometimes, they have to do some basic things like conversion of numbers. Sometimes, they have to look up stuff like the Colors enum. Your two colors here are Color.Black and Color.Transparent ( as it's ARGB ).
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
"Value of type 'System.Drawing.Brush' cannot be converted to 'System.Windows.Media.Brush'"
BAH!!
|
|
|
|
|
Well, you need to explicitly scope it. I think if you want to use the build in ones, it's Brushes, not Brush, too. My bad.
I would agree that MS having objects of the same name in different namespaces is a PITA.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I think I saw people doing this back in the VB6 days, here is the VB.Net version
Private Function ConvertHexToColor(ByVal strInput As String) As Color<br />
<br />
strInput = strInput.Replace("#", "")<br />
<br />
Dim alph As Integer = 0<br />
Dim red As Integer = 0<br />
Dim green As Integer = 0<br />
Dim blue As Integer = 0<br />
Dim colToReturn As Color = Color.FromRgb(red, green, blue) 'default if input is invalid<br />
<br />
If (strInput.Length = 6) Then<br />
'RRGGBB<br />
red = Convert.ToInt32(strInput.Substring(0, 2), 16)<br />
green = Convert.ToInt32(strInput.Substring(2, 2), 16)<br />
blue = Convert.ToInt32(strInput.Substring(4, 2), 16)<br />
colToReturn = Color.FromRgb(red, green, blue)<br />
ElseIf (strInput.Length = 8) Then<br />
'AARRGGBB<br />
alph = Convert.ToInt32(strInput.Substring(0, 2), 16)<br />
red = Convert.ToInt32(strInput.Substring(2, 2), 16)<br />
green = Convert.ToInt32(strInput.Substring(4, 2), 16)<br />
blue = Convert.ToInt32(strInput.Substring(6, 2), 16)<br />
colToReturn = Color.FromArgb(alph, red, green, blue)<br />
End If<br />
<br />
Return colToReturn<br />
<br />
End Function
to use:
<br />
Public MainMenu_Background As Brush<br />
MainMenu_Background = New SolidColorBrush(ConvertHexToColor("#FF000000")) 'Black<br />
myControl.Background = MainMenu_Background<br />
hopefully .Net 4.0 will see an improvement like this
|
|
|
|
|
There is ColorConverter, which is the TypeConverter WPF uses.
this.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00FF00"));
|
|
|
|
|
Hi,
I have 3 check boxes.. 1.select all 2. team1, 3. team2.
If i check Select all , then all the 3 check boxes should be checked.
If I unselect team1 or team2 after i have checked selectall, then selectall should be unchecked and team1 and team2 still be checked.
--> on select all, all 3 should be checked..
--> on unchecking either team1 or team2 after checking select all, then select all shuld be unchecked.
--> individual checking is allowed.
I am able to do for the select all but not successful in the second half.
Please help me.
Thanks
Ramm
|
|
|
|
|
Hi,
Is there any way in which I can change this property without overwriting the entire control template. I've seen this done in some examples but I can't set the template for the DatagridColumnHeadersPresenter in my xaml file. I can access the headers and style them. I'm a bit new to control templates in wpf. Any help would be appreciated.
|
|
|
|
|
Hi,
I am working on WPF 3.5 SP1 using Visual Studio 2008. My developed applications are not running on various machines which also has .Net 3.5 SP1. In some machines they are working fine & in others they failed to load.
I checked everything including code, but didn't find anything to resolve. Can anyone please help me asap to resolve the same issue? Your kind help is highly appreciated.
Regards,
- Kunal
|
|
|
|
|
Try 2 log exception details or just check vats the exception.Otherwise how can u fix that?
|
|
|
|
|
Not sure what specific help you expect here, except to point out the obvious - check the specs of the machines in question, check their video card drivers, tell us what error you get when they fail to load, etc.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi Chris,
After doing a deep debug, I came to know that, it is throwing "FileFormatException" for image: "The image format is unrecognized".
I am using gif/jpg/png formats. I also tried replacing the gif image with a new png image. In that case also, it is throwing the same exception & refuses to run. The image source is specified in the XAML in the following syntax: "images\myLogo.png"
FYI, it is working fine in my development PC & other PCs having Windows 7, but, it is refusing to run on Windows XP & Vista machines.
What could be the reason? Any idea???? Please HELP...
Regards,
- Kunal
|
|
|
|
|
I removed all the references to the images in my solution...
Still it is throwing the same error...
Any other way to check it???? Pls. help...
Regards,
- Kunal Chowdhury ( My Blog)
|
|
|
|
|
All you can really do, is catch any exceptions at the top level. and write them to a log. You seem to have already worked out that it relates to what OS is being used, so the question becomes, what's present in one OS and not the other, and can you install it. Might updating an IE version help ? Might updating WMP help ? ( WPF apps will just crash in XP if you have not updated the version of Windows Media Player, with a pretty meaningless error message )
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I checked the exception log but it is meaningless. It is only throwing bad image format exception.
I removed all the images & also the reference to the images from the xaml. Still it is there.
As the exception message is not proper, it is really very difficult to find the issue from that.
Is there any other way to find & resolve the same issue? I didn't find anything...
Regards,
- Kunal
|
|
|
|
|
But Cris.... My other WPF programs are running fine on those machines. Only the said code is not running. To resolve it I created another project in VS2K8 & copied my code. That is also not working. I have not used any Windows7 reference, FYI. Please guide me....
Regards,
- Kunal
|
|
|
|
|
Chris,
That was due to different icon format. I changed the format from 4 bit to 8 bit BMP & now it is working fine...
Regards,
- Kunal Chowdhury ( My Blog)
|
|
|
|
|
Hi All,
I want to access a UIELEMENT timepicker's (which is in a datagrid column), IsEnabled attribute through C# code not the XAML.
for eaxmple a timepicker control is in the 8th column,
how can I do this
dataGrid1.Columns[8].timepicker.IsEnabled=false;
Any suugesstions?
modified on Wednesday, September 16, 2009 3:51 AM
|
|
|
|
|
I've just discovered a bit of WPF ListBox stupidity. If you have a data-bound ListBox , and you set the SelectedItem programmatically, the item you picked is indeed the selected item when the control is displayed. If you use the keyboard to move the selection, however, you find out that the focus item is the first item in the control. On your keypress, the ListBox moves the selection to the first item in the control, rather than the item before/after the previously selected item. Dumb.
Fortunately, the fix is easy. In the Loaded() handler for the container of your ListBox , add the following:
private void _Loaded(object sender, RoutedEventArgs e)
{
if (List.SelectedIndex >= 0)
{
ListBoxItem item =
(ListBoxItem)
List.ItemContainerGenerator.ContainerFromIndex(List.SelectedIndex);
item.Focus();
}
else
{
List.Focus();
}
} Note that the ListBox instance is named List in this example, and this code assumes that the ListBox has the focus when the window is loaded.
Software Zen: delete this;
|
|
|
|
|
Hi,
I am working on a silver light application. In this I have a canvas on which I will drag and drop some components (which are usercontrols and displayed beside the canvas). After placing them on the canvas if I drag them they will move to desired location on the canvas. Here my problem is that if I drag them out of this canvas they are even moving out of the canvas. But I want these components to move only inside the canvas and they should not move out of this canvas.
If anyone have any idea to fix the components to move inside the canvas please reply me.
Thanks in advance.
|
|
|
|
|
If you are using Silverlight 3 use built in MouseDragElementBehavior for Dragging a control and set ConstrainToParentBounds to true.This is more easier than manual adjustment of left and top attributes inside a canvas.
|
|
|
|
|
Hi Arun Jacob,
Thanks for your reply.
I tried to implement this in my solution. I tried to set ConstrainToParentBounds to true for my usercontrols such that these usercontrols will not move out of the canvas when I place them on the canvas in the MainPage.xaml. But I am unable to get this property for my user control.
Please reply me how I have to set this property for a usercontrol.
Thanks in advance.
|
|
|
|
|
Hi I have Visual Studio Team System 2008..I want to develop Silverlight applications.Is it possible to install silverlight controls?If not what to do?
CC26
|
|
|
|
|