|
As I understood , I have to use something like this ! yeah ?
listview.ItemsSource = new byte[] { 0, 1, 2, 3 };
But it doesn't work 
|
|
|
|
|
You haven't bound any of your columns to a member of your collection, so nothing will show.
Typically you'd do something like this:
public class MyItem
{
public string ID { get; set; }
public string Number { get; set; }
public string Name { get; set; }
public string LName { get; set; }
}
public class MyItemCollection : ObservableCollection<MyItem>
{
}
...
listview.ItemsSource = new MyItemCollection();
<ListView Name="listview" Margin="158,106,156,128">
<ListView.View>
<GridView>
<GridViewColumn Header="ID" DisplayMemberBinding="{Binding Path=ID}"/>
<GridViewColumn Header="Number" DisplayMemberBinding="{Binding Path=Number}"/>
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding Path=Name}"/>
<GridViewColumn Header="LName" DisplayMemberBinding="{Binding Path=LName}"/>
</GridView>
</ListView.View>
</ListView>
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have a style defined in a resource dictionary that I'm merging in the app.xaml file. How do I make usercontrols in a separate assembly see the styles in the merged dictionary?
"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
|
|
|
|
|
Just to make sure I am understanding correctly:
Assembly A has some UserControls
Program B has some Resources and references Assembly A
You want the UserControls from A to use styles defined in B.
If that is what you are trying for, I have been able to use {DynamicResource StyleInB} on the UserControls (instead of {StaticResource StyleInB}).
|
|
|
|
|
I have some styles in a resource dictionary. The dictionary is merged in app.xaml file. I have other user controls in a class library, but they can't see the styles defined in the merged dictionary. What do I have to do to make that happen?
"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
|
|
|
|
|
If I understand your question correctly, this[^] should solve your problem. Please inform me if it is what you're looking for.
Eslam Afifi
|
|
|
|
|
All of my applications are designed this way.
MainApp.exe - has merged resources
LibraryOne - no resources, uses resource in MainApp.exe. Does not reference MainApp.exe. Resources here all use the DynamicResource mark up extenstion when assigning them.
LibraryTwo - no resources, uses resource in MainApp.exe. Does not reference MainApp.exe. Resources here all use the DynamicResource mark up extenstion when assigning them.
LibraryThr - no resources, uses resource in MainApp.exe. Does not reference MainApp.exe. Resources here all use the DynamicResource mark up extenstion when assigning them.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
I'm sorry I couldn't reply to your message earlier because I was having exams and projects. I couldn't understand your message back then so I decided to get back to it after exams with a clear mind. Finally I got the time to try to understand it again and I'm confused.
Karl Shifflett wrote: All of my applications are designed this way.
MainApp.exe - has merged resources
LibraryOne - no resources, uses resource in MainApp.exe. Does not reference MainApp.exe. Resources here all use the DynamicResource mark up extenstion when assigning them.
Why do all your applications has the resources in the exe and the dlls uses these resources?
Trying to understand, I wrote some code trying to apply what you described and I don't know If it's what you meant or not.
Class1 in a library that doesn't reference the exe.
public class Class1
{
public static void Foo()
{
var resourceDictionary = new ResourceDictionary()
{
Source = new Uri(@"WpfApplication4;component\Dictionary1.xaml", UriKind.Relative)
};
Debug.WriteLine(resourceDictionary["msg"]);
}
}
The exe (which references the library which reside in the same directory) has Dictionary1.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mscorlib="clr-namespace:System;assembly=mscorlib">
<mscorlib:String x:Key="msg">Hello, world!</mscorlib:String>
</ResourceDictionary>
Then the exe calls the Foo method in the library (in debug) somewhere.
I don't know if this is near what you described or not. Or is it that the exe doesn't reference the dlls and use resources defined in the dlls and load them from code? It'd be great if you clarify this. Thank you.
Eslam Afifi
|
|
|
|
|
|
Mr. Karl,
Thank you so much for clarifying and the link for the article. Now I see why and how it works. I like the article, very useful , planning to read the available parts and waiting for the upcoming parts.
Eslam Afifi
|
|
|
|
|
Eslam,
Glad to help out. Have a great day!
modified 27-Feb-21 21:01pm.
|
|
|
|
|
|
I have a custom control which dynamically add texboxes...This control is inherited from StackPanel....
Now I have a collection of textboxes which will dynamically added to the StackPanel.
I want to add a message control below each text box and manually hide and show that...which will have hanging kind of look...
My question is that, how can I add the message control dynamically below each textbox control?
I think I am trying to get the X, Y coordinates of the textbox on mousemove event and trying to place the message control but not able to get any result...
Can anybody help me?
Thanks in advance,
|
|
|
|
|
Not tried it yet, but I think if you just add controls to a stack panel that has its orientation set of vertical, they get added in first-in order. This should just keep putting then one under the next.
As far as I know the insert method of the stack panels children collection allows for an index number to be given though, so you could do it that way also I guess.
|
|
|
|
|
salon wrote: Now I have a collection of textboxes which will dynamically added to the StackPanel.
An alternative to doing all this manually from code would be to
use a collection of a data type that has the required properties
for each item. Then using an ItemsControl (or derived) you can use a data
template for the items, so each time you add an item to the collection, all
the UI elements for the item will be magically created using the template.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all,
I have Inkcanvas on which i am trying to place images. now i m trying to rotate the image from the centre intead of top left position so after creating the image i have passed 0.5 value to the image property. the transformation does not happen... i have tried passing imagewidth/2 and imagehieght/2 but both fails..
Can any one suggest me a way to solve this... i have alse made the canvas width and height to constant values.
Thanking in advance
Samir
|
|
|
|
|
Hi there, excuse my bad english
I wrote a Style on my dictionary that change the border's borderbrush (to pink). I ran the program and everything look great. (I'm running Vista).
Well, I send it to my girlfriend and she has XP. In XP the program show double borders everywhere, tabs names with double pink border, the border with another border (¿Usercontrol border?)...
I remember the lesson about Visual trees, and I think that these items have and implicit border and the style applies to they too.
The question is, why I saw the changes only in the borders that I explicit put and not the others?
I hope you can understand me.
Long live to codeproject 
|
|
|
|
|
You have to force the app to use the vista aero theme.
<application x:class="WPFApplication1.App" xmlns:x="#unknown">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="WindowMain.xaml">
<application.resources>
<resourcedictionary source="/PresentationFramework.Aero;V3.0.0.0;31bf3856ad364e35;component/themes/aero.normalcolor.xaml" />
</application.resources>
</application>
Don't forget to add a reference to PresentationFrameworkAero . When you do this, even XP will show Aero-style control appearance.
"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
|
|
|
|
|
You have learned well young Padawan. The force is strong in this one.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I used the Google Force to find the answer for myself.
"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
|
|
|
|
|
Thanks you very much.
It's work perfectly and I have not to worry with this weird behavior in XP thanks to this little black magic :P
Thanks you again. 
|
|
|
|
|
WPF is only half finished. When VS2010 is released, we'll get a little more of it.
"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
|
|
|
|
|
The Codeplex WPF site[^] is a good place to get your hands on controls
before they are rolled into the framework.
The WPF Toolkit has had a date/calendar control for a while - not sure
about a time picker...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
So all of those were fixed? If not, how many apply to your potential
usage of the control?
I've personally used the control, including in data grids, with no
issues. As with everything else in Windows, your results may vary.
Have you googled for other controls? There's tons of companies providing
WPF components - many with their own issues
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
That is the list of fixes.
As it's always been with Windows programming - if there isn't a
system-provided control that suits your needs, you write your own.
At least WPF makes it easier than ever.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|