|
Hi Pete,
Really nice code.
actually i implement this code but i get below error in .xaml file
Error 1 The property 'HelpKey' does not exist in XML namespace 'clr-namespace:TestWPFHelp'. Line 14 Position 107.
and here is my .xaml code
<Window x:Class="TestWPFHelp.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:help="clr-namespace:TestWPFHelp"
Title="Window1" Height="300" Width="300">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBox Grid.Column="1" Height="23" Margin="78,72,80,0" Name="NameFiled" VerticalAlignment="Top" help:HelpKey="MyName" />
</Grid>
</Window>
i m new to wpf and i don't know how i resolve it...
if u have any idea then plz let me know..
Thanks in advance
Krishnraj
|
|
|
|
|
Hi there.
I want to handle Enter key or Space bar key on richTextBox in WPF.
By KeyDawn event I couldn't do it.
Can you help me ?
Freshman
modified on Friday, July 4, 2008 10:43 AM
|
|
|
|
|
What do you mean you want to handle the enter key or space bar? What exactly are you trying to achieve?
|
|
|
|
|
OK.
I have a richTextBox. Now I want to know when ENTER key pressed in my richtextbox.
Can you understand what I mean?
Freshman
|
|
|
|
|
Well, you can use the PreviewKeyDown attached event to handle this. Google it to find out all about it.
|
|
|
|
|
Great. Thank you very much.
Freshman
|
|
|
|
|
Hi All,
I am new to the SilverLight beta 2.
I am having 2 SiverLight user controls.
I want to use 1 SiverLight user control on the one aspx page say 1.aspx.
and other SilverLightControl on the other aspx page say 2.aspx.
How would i do this functionality.
Thanks in advance
Iam wating fr your valueable reply......
Regards,
Sumukh
sam
|
|
|
|
|
Hello Sumukh,
Let me tell the structure of Silverlight 2.0.
--XAP Package
----App
------SilverlightPage
----------SilverlightControl
If you want to show Silverlight on webpage, you have to show XAP package. (not App, Silverlight Page, Silverlight Control). This is the first thing you may want to know.
Another thing: you want to display two different Silveright Content in two different aspx pages, right? There are two ways to go ~
1) Create the seperated projects - Let's say you want to show SilverlightClock on 1.aspx and SilverlightMap on 2.aspx. So, create one silverlight project for SilverlightClock and create another project for SilverlightMap. After complied, you will get SilverlightClock.xap and SilverlightMap.xap. Show those xaps on aspx page.
2) You can create one Silverlight project. Create two silverlight controls for clock and map. And you can pass the parameter by using "InitParam" from aspx to Silverlight. You can receive that parameter from App.xaml.cs. Based on that parameter, you can decide which control you want to show. There are a lot of examples (including some of my own) in Silverlight Forum. You can search it if you want.
|
|
|
|
|
Hi Michael,
Thanks for your quick reply.
i think the second approach you suggested is fit for my application.
Could you please elaborate or give me some information link about the above approach?
Thanks & Regards,
Sumukh.
sam
|
|
|
|
|
As you know, there are three ways to show the Silverlight content on the webpage.
1) OBJECT tag
2) asp:Silverlight control from ASP.NET 3.5
3) Silverlight.js
No matter which approach you use, you are able to pass the parameter by using "InitParams" properties. You will be able to accept those parameters from App.xaml.cs. Let's say you pass 1 as a parameter and you will get the 1 from App.xaml.cs. So, if you get 1 then you should show Page1.
There are a lot of examples in Silverlight forum and you can search "InitParam"...
|
|
|
|
|
Hi Michael,
I am elaborating the scenario here:
I am having 1.aspx and 2.aspx these 2 pages.
Also I am having 2 silverlight control.
I have displayed the one of the silverlight control in the 1.aspx.In 1.aspx there is hyperlink which will navigate me to the 2.aspx.
Now, my requirement is i want to mount the second silverlight control on the 2.aspx.
Waiting for your reply,
Thanks & Regards,
Sumukh
sam
|
|
|
|
|
You may use either Object or CreateObject or CreateObjectEx to achieve this.
You need to pass an initialization parameter to it.
Here is a link which I have followed to create such an application:
http://msdn.microsoft.com/en-us/library/cc265155(VS.95).aspx[^]
Best Regards,
Sam Xavier
www.componentone.com
|
|
|
|
|
You can take a look at my reply. I already told him that he can use initparam but he explained me his scenario again.. ..
|
|
|
|
|
Hi Michael,
Could you please explain me with an example?
Thanks & Regards,
Sumukh
sam
|
|
|
|
|
Hi Sam,
I clicked on the url but not found.
Could u please give me some example?
Thanks & Regards,
Sumukh
sam
|
|
|
|
|
Hello All,
Let's say I have the existing WPF application. There are two kinds of clients who are willing to install my software on their machine and who prefer to use my software like web application without installing on their machine.
I don't like to have two seperated applications (WPF Application and Silverlight Application). I just want to have one application so I'm not so sure what I should do. During these days, I'm just surfing around the internet and collecting the information to make good decision.
1) I think it would be fine if I keep WPF application with ClickOnce for those clients who are willing to install my software on their machine. Can I have an XBAP for those are not happy to install my software? Actually, I don't want to have the seperated applications such as WPF and XBAP. I will have only WPF application but when I deploy that project, I will deploy with ClickOnce once and I will deploy it as XBAP once. Is it possible to do? or Is there any way to convert the WPF project to XBAP project in very easy way? or should I have two differnet applications for two different users?
2) I know there are some differences between WPF and XBAP. Here is the list that I found. Could you please correct me if I'm wrong?
2.1) The client need to install .NET 3.0 or above.
2.2) Coperate Proxy may block the exe file for Xbap application.
2.3) XBAP runs on sandbox so that it has the following limitations
---------Windows and Popup won't work. We need to convert it as a Page.
---------can't use BitmapEffects and Image Encoding
---------Only run in IE6/7/8 browsers and Firefox
---------supports only Windows XP SP2 and later, Server 2K3 and later, and all flavors of Vista
---------XBAPs doesn't work in Windows Vista Sidebar, ActiveX does!
---------You cann't connect the database directly.
---------unable to load a custom mouse cursor in an xbap
---------SaveFileDialog
---------Cross Domain Access
---------File System & Registry Access
---------WindowsForms Interop ("Crossbow")
---------XAML Serialization (via XamlWriter.Save)
---------Full Speech Support
---------RTF Clipboard
---------Full XAML Clipboard Support
---------Drag & Drop
---------HwndHost
3) Some articles said that if we are using ClickOnce, the application will be installed to the client machine. but if we are using XBAP then, it won't install to the client machine and it will be cached. Based on my research, I totally don't agreed with this statement. Xbap application will be downloaded into the Application Cache like what ClickOnce does. (except it won't show in Add/Remove Program and StartMenu). What do you say?
4) no built-in way for XBAPs to prompt and request more permissions but it is possible to use ClickOnce-based methods to gain access to trusted actions
References:
http://scorbs.com/2006/11/09/wpf-internet-sandbox-feature-list-xbaps-loose-xaml/
http://www.charlespetzold.com/blog/2006/11/120718.html
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1536464&SiteID=1&mode=1
http://www.wpflearningexperience.com/?p=23
|
|
|
|
|
Hi
I'm creating a Windows Forms Application with an WPF Element Host.
I want to the user to set the background of an WPF element with use of a ColorDialog.
So I need to convert the System.Drawing.Color to a System.Windows.Media.Brush.
I got it to work when the Color is a NamedColor (isNamedColor) but else I cannot get it to work.
System.Windows.Media.BrushConverter bc = new System.Windows.Media.BrushConverter();
if (_color.IsNamedColor)
{
ColorBrush = (System.Windows.Media.Brush)bc.ConvertFromString(_color.Name);
}
else
{
???????????
}
What should I put at the ?????????
|
|
|
|
|
You can use Color.FromArgb to generate the appropriate values.
ColorBrush.Color.FromArgb(_color.ToArgb()); I'm doing this off the top of my head, so you may need to tweak it slightly but this should work.
|
|
|
|
|
The System.Windows.Media.Brush ColorBrush doesn't contain anything like Color or FromArgb. Neither does the BrushConverter.
|
|
|
|
|
Colours and Brushes are two different things. As mentioned above you can access the components of the colour individually to swap between a System.Drawing and a WPF color.
using (System.Windows.Forms.ColorDialog d = new System.Windows.Forms.ColorDialog())
{
d.ShowDialog();
System.Drawing.Color c = d.Color;
Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(c.A,c.R,c.G,c.B));
}
|
|
|
|
|
I Found It.
System.Windows.Media.BrushConverter bc = new System.Windows.Media.BrushConverter();
if (_color.IsNamedColor)
{
ColorBrush = (System.Windows.Media.Brush)bc.ConvertFromString(_color.Name);
}
else
{
ColorBrush = (System.Windows.Media.Brush)bc.ConvertFromString("#"+_color.Name);
}
When it is not a NamedColor it returns for example ffffff80. When you add a # it recognizes and converts it.
Thanks Anyway
|
|
|
|
|
System.Drawing.Color c1 = new System.Drawing.Color();
c1 = System.Drawing.Color.FromName(mycolorString);
System.Windows.Media.Color c2 = new Color();
c2 = Color.FromArgb(c1.A, c1.R, c1.G, c1.B);
modified on Saturday, April 16, 2011 11:21 AM
|
|
|
|
|
Hy! I'm trying to bind a given color to a rectangle in WPF... by now without success.
Here's my not working) approach:
XAML:
<Rectangle Fill="{Binding Path=color1}"
Margin="10,10,10,10"
Height="Auto" Width="Auto"
Grid.Column="0" Grid.Row="0"
/>
...
C# Code:
public Window2()
{
InitializeComponent();
bgColors.SetColors(Colors.Green, Colors.Green, Colors.Red, Colors.Red);
MainDockPanel.DataContext = bgColors;
}
and
internal class BGColors : INotifyPropertyChanged
{
private Color Color1;
public Color color1
{
get { return Color1; }
set { Color1 = value;
NotifyPropertyChanged("color1");
}
}
private Color Color2;
public Color color2
{
get { return Color2; }
set { Color2 = value;
NotifyPropertyChanged("color2");
}
}
private Color Color3;
public Color color3
{
get { return Color3; }
set
{
Color1 = value;
NotifyPropertyChanged("color3");
}
}
private Color Color4;
public Color color4
{
get { return Color4; }
set
{
Color2 = value;
NotifyPropertyChanged("color4");
}
}
public void SetColors(Color color1, Color color2, Color color3, Color color4)
{
this.color1 = color1;
this.color2 = color2;
this.color3 = color3;
this.color4 = color4;
}
private void NotifyPropertyChanged(string p)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(p));
}
}
public override string ToString()
{
return color1.ToString();
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
#endregion
}
Binding the values as string to a label works perfectly, but no Colors can be assigned.
Help would be appreciated.
Thx in advance
|
|
|
|
|
When a data binding is not working, the first place to look is the Immediate Window. The message I got when trying your code is:
Cannot create default converter to perform 'one-way' conversions between types 'System.Windows.Media.Color' and 'System.Windows.Media.Brush'.
Either you will need to change the BGColors class to give brushes, or you will need to write a converter.
|
|
|
|
|
Also - make sure that the Color type you are binding is of the right kind. You can't bind a System.Drawing.Color to a WPF element - you need to use a System.Windows.Media.Color type. I got caught by this not so long ago and it had exactly the symptoms you describe - no problem reported however the color was ignored.
Melbourne. Australia.
modified 10-Jul-19 21:02pm.
|
|
|
|