|
Ok, thanks
I tried that before but it doesn't seems like it's possible to use the startup Window1 class. Think I have to create a separate class behind my resource file and go from there...
|
|
|
|
|
mikla521 wrote: it doesn't seems like it's possible to use the startup Window1 class
Yes. ResourceDictionary is a different class than Window
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I've recently decided to look into adding the ability to load WPF Windows to one of my pet projects. I also want to allow it to process speech, and other goodies. To achieve this, I've created a new class in my 'host' Windows Forms application, which inherits from System.Windows.Window. The requirements for a Window to be loaded are:
- It must have an attribute which contains the name, category, etc.
- It must inherit from my custom class
I have no problem with the first one, but the second one is where I fall down. I have added a reference to the 'host' application in the 'parasite' (sorry, don't know how else to describe it) application, and changed the C# back-end class to inherit from my custom class. When I try to build, I get this error
Partial declarations of 'SampleWPFMiniApp.wndMain' must not specify different base classes
I presume the designer is similar to that of Windows Forms in that the code is split between XAML and code. How would I specify the correct base class in XAML? For what it's worth, the base class I specified in my C# code is Host.ShellComponents.ParasiteWindow
|
|
|
|
|
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 ?
|
|
|
|
|