|
There's no need to worry about my original post. By adding xmlns:src="clr-namespace:Host.ShellComponents.ParasiteWindow;assembly=Host" along with the other xmlns XAML, and then setting the root element to src:ParasiteWindow , I can compile successfully. But now I have another problem. How do I host a WPF Window (or equivalent) in a Windows Form? I've been trying to use the System.Windows.Interop.WindowInteropHelper class, and this shows the Window, but not as a child of the Windows Forms host
|
|
|
|
|
I have the following style:
<Style TargetType="{x:Type Image}" >
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button},
AncestorLevel=1}, Path=IsEnabled}" Value="False">
<Setter Property="Opacity" Value="0.40" />
</DataTrigger>
</Style.Triggers>
</Style>
Where do I put it if I want it to be global to the application, and how do I get to it once it's there?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
|
I tried that and it kept telling me something about content already having been defined. BTW, I was trying to put it inside the Application.Resources element.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Currently the way you have it defined
<style targettype="{x:Type Image}"></style>
this assigns this style to all of the image types within the scope. If you have this definition elsewhere (Window.Resources or elsewhere) you could have a conflict. If you want to have it only affect a select few controls you can add a key to it reference it on the controls you want it to be used on.
Have you looked at WPF Themes project? http://http://www.codeplex.com/wpfthemes[^] I believe they are doing something similar to what you want.
Richard
|
|
|
|
|
You can find a description of the resource lookup behavior here:
WPF: Resources Overview[^]
That may help you coose the most appropriate place.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I've already been there and it was no help.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: global to the application
If I have a style or template that I want to be global I use a MergedDictionary, for example.
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Dictionaries\Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
John Simmons / outlaw programmer wrote: how do I get to it once it's there
You would access the style/template using the key you define for it.
Resource dictionary:
<ControlTemplate x:Key="NormalButtonTemplate" TargetType="{x:Type Button}">
snip...
</ControlTemplate>
Then in your xaml you would assign it using the key in this case:
<Button Template="{DynamicResource NormalButtonTemplate}" />
Hope that helps
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
It is possible to put your Style in the App.xaml with the <application.resources> and that will put your style at the application level and in order to access it you can Style="{StaticResource (Name Here)}" and that will get your Style from the application resources.
|
|
|
|
|
You could also put these in a separate Style dll altogether ...
|
|
|
|
|
Consider the following code:
<Canvas Panel.ZIndex="999" HorizontalAlignment="Left" Width="225" Height="262" VerticalAlignment="Top">
<Expander Margin="-13,-47,0,-210" Name="expander1" Background="Transparent" HorizontalAlignment="Left"
Width="221" Height="257" Canvas.Top="48" Canvas.Left="14">
<Expander.Header>
<Rectangle Height="26" Margin="22,-21,0,0" Name="rectangle1"
Stroke="OrangeRed" VerticalAlignment="Top" RadiusX="8" RadiusY="8" Fill="DarkBlue" />
<Label Margin="22,-20,0,0" Background="Transparent" Foreground="White" Name="label99"
FontFamily="Arial" FontSize="14" FontWeight="Bold" FontStyle="Italic"
HorizontalContentAlignment="Center"
Content="BTN:123-456-7890" Height="26" VerticalAlignment="Top" />
</Expander.Header>
<Grid >
<Grid.BitmapEffect>
<DropShadowBitmapEffect />
</Grid.BitmapEffect>
<telerik:RadTreeView blah blah blah />
</Grid>
</Expander>
</Canvas>
The designer is giving the following error:
The property "Header" is set more than once.
I don't understand why I'm getting this error - there's only one header specification in the control.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I'm not an expert at all but in this case you just can't use several controls inside the header.
Instead you can use a Grid or Stackpanel or similar and there put your Rectangle and Label.
|
|
|
|
|
It is because you are trying to add two elements the Rectangle and Label. You can put both inside a grid or other kind of panel or maybe you could put the label inside a border and not need the Rectangle.
|
|
|
|
|
Expander.Header is an object not a collection. You can't put both a rectangle and a label in it. Put only one object.
Eslam Afifi
|
|
|
|
|
I have one MFC control,which one i create, and I convert this as a .dll file and add a System::Windows::Forms::UserControl to this dll and whit the help of this Usercontrol I can load this control in WinForm application.
I need to use this control in WPF application, with out using the System::Windows::Forms, So, i think, I need to add a System::Window::Controls::UserControl to the dll and convert this as a UIElement^. But I have no idea how to do this. If you have some idea, or any help pages in internet, how to create a System::Window::Controls::UserControl from a MFC dll please help me.
|
|
|
|
|
|
I have a datagrid with a DataGridTemplateColumn. The DataTemplate is a Image wrapped by a Button.
<wpftoolkit:DataGridTemplateColumn Header="Search Type" IsReadOnly="True" >
<wpftoolkit:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button x:Name="btn" Width="25" Height="25" >
<Image x:Name="icoDisplay" Source="../Resources/plus.png"></Image>
</Button>
</DataTemplate>
</wpftoolkit:DataGridTemplateColumn.CellTemplate>
</wpftoolkit:DataGridTemplateColumn>
I'm trying to change the image source when a row is selected. I want to show an image with a "+" when the details for a row are not showing. I want to show an image with a "-" when the details for a row are showing. I want to change the image source when the row is selected in any cell of the row, not just when the button/image are selected. I don't have to have the button there if it can be done without it.
Any help with this would be greatly appreciated.
|
|
|
|
|
Hi,
I have a WPF DataGrid (from WPFToolkit) which dispays the results of several queries from a database.
I am returning the results to a datatable and then setting the DataContext of the DataGrid to = the DataTable, so no Binding.
I need to programatically format the "StringFormat" of each column at runtime ie. for Date - "dd MM yyyy" etc.
This is very easy to do with a normal windows forms DataGridView but looks to be nearly impossible to do with the WPF Datagrid.
I cannot create the columns in XAML as I do not know what they will be, every query is different and can change what it returns.
I have spent 2 days trying to resolve this issue, and have not found a single post which actually solves this problem.
Any help would be much appreciated.
Thanks
|
|
|
|
|
Just Use AutoGeneratedColumns Event of the DataGrid:-
In the below mentioned example DataGrid Name is "dgvTimming"
void dgvTimming_AutoGeneratedColumns(object sender, EventArgs e)
{
foreach (DataGridColumn item in dgvTimming.Columns)
{
switch (item.Header.ToString())
{
case "Plan_Timing":
item.Header = "Plan Timing";
break;
case "Pacesetter":
case "Contingent":
if (item.GetType().ToString() == "Microsoft.Windows.Controls.DataGridTextColumn")
{
DataGridTextColumn dg = (DataGridTextColumn)item;
dg.Binding.StringFormat = "C";
}
if (item.Header.ToString() == "Contingent")
item.IsReadOnly = true;
break;
}
}
}
Yogesh Sharma
|
|
|
|
|
hi
i work somewhere as a programmer
i know somethings in c#
and you know i want to use the WPF
and want to know where should i start it
please tell me which book,tutorial or other material is the best start line for an absolute beginner in WPF
thank you all that kindly help me to be improved and so be happy
just improvement cause real happiness
thank you everybody
|
|
|
|
|
here the book name
Sams - Teach Yourself WPF in 24 Hours
You have To Search About The Truth Of Your Life
Why Are you Here In Life ?
|
|
|
|
|
|
How do I go about adding a 'Command' property to a custom WPF control derived from an existing control? I want to use the Command property the same way you would use a Command property on a button--to bind to any ICommand or routed command.
I rely heavily on MVVM, and my UI controls are almost always bound to ICommand objects in my view model. I have started using the Actipro Wizard control for my WPF wizards, and it's very good. But it's missing one thing: It won't let you bind a command to the activation of a wizard page.
In many wizards, a process should start automatically when a wizard page is activated. For example, in a file copy wizard, pages 1 and 2 get file paths from the user, and when the user advances to page 3, the copy should begin automatically, displaying a progress bar for the operation.
Unfortunately, the Actipro WizardPage doesn't have a Command property that fires a command when the page is activated. It does have a 'Selected' event, which I'm using now. But I would rather bind to a command in XAML, so I am extending the ActiPro WizardPage control to add a 'Command' property that will fire when the page is activated.
Can anyone point me to any articles or blogs on how to implement a 'Command' property and give the derived control the CanExecute() behavior expected of a command-bound control? Thanks.
David Veeneman
Foresight Systems
|
|
|
|
|
Found my answer. A derived control that wants to implement a Command property must implement the ICommandSource interface. There is an MSDN article[^] that shows how to do it, as well as a code sample[^].
David Veeneman
Foresight Systems
|
|
|
|
|
Hi,
I have a WPF textbox and I want to validate the text the user types i.e. only numbers are allowed. To do this I have set
<pre>Text="{Binding MobileNumber, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}</pre>
And the property is
<pre> public string MobileNumber {
get {
return mobileNumber;
}
set
{
if (AllowedPhoneNumberCharacter(value))
mobileNumber = value;
OnPropertyChanged("MobileNumber");
}
}</pre>
If the user types a character we came to <i>set </i> and after OnPropertyChanged("MobileNumber"); a call to <i>get </i>is made. But the textbox is not updated, why?
Example:
09876 :User types o phone number. OK
098767 :User adda a digit 7. OK
098767g :Not OK to add g. Now I want to update textbox with 098767.
Regards
Marc
|
|
|
|