|
I'm doing the same and having a problem with it. At present I have code behind that links to a canvas but want to move the code to the viewmodel
<Canvas x:Name="LayoutRoot" >
<TextBlock Text="{Binding Path=Items}" />
</Canvas>
Code behind causing the problem
ticker = new Ticker<TickerItem>(LayoutRoot);
And the public class that needs a panel
public Ticker(Panel container){...}
Any help on this would be great thanks
|
|
|
|
|
Never mind... I figured it out!
I just needed to add
<Canvas x:Name="LayoutRoot" >
<TextBlock Text="{Binding Path=Items}"/>
<ContentPresenter Content="{Binding Path=LayoutRoot}" />
</Canvas> And create a new Canvas object in the viewmodel
public Canvas LayoutRoot{ get; private set; }
public viewModel
{
LayoutRoot= new Canvas();
ticker = new Ticker<TickerItem>(LayoutRoot);
}
|
|
|
|
|
I am trying to implement a Drag and Drop labeling system like Gmail uses. Just a list of labels that can be dragged atop any entity in my system. All entities in the application will extend from a base class that will accept the label-drop and adorn itself appropriately with the dropped label. I need to be able to multi-select labels and drag them as well!
any ideas? I've seen a number of drag and drop examples, but none of them are like a labeling system!
|
|
|
|
|
Shafique,
Best option would be to take one of the examples you've found, and change it to implement what you want..
Take this example for instance..
Drag and Drop Items in a WPF ListView[^..
If you add a 2nd list of labels, and use the existing list as your "entities", and work at it from there.
|
|
|
|
|
the way i see, i should have two Tree's. One Tree will be for favorites, and the other tree will be for Non-favorite labels. what do you think?
I think the link you sent looks pretty helpful..
thanks!
|
|
|
|
|
Hi All,
I started developing simple application in WPF and XAML.
I want to try accessign the sql server database and display the data from stored procedure onto the UI form.
I have a table called parentProject -> idParentProject (pk), txtParentProjName varchar(max).
my SP is parentProj_sp -> select * from parentProject.
n
I want to use a dropdown list in which, If the sp returns say (3) records, then dropdownlist should have those 3 records retreived from sp.
similar manner, I have subproject -> idsubproject(pk), idParentProject , txtSubProjectName varchar(max), dateProjstart, dateprojectend.
once the parentprojectname is selected from first dropdown, then, subproject dropdown should be enabled and it should have the subprojectnames for the corresponding parent project.
my sp is subproject_sp -> SELECT dtProjectStart, dtProjectEnd FROM tblSubProject WHERE (idParentProject = @idProjectIndex).
please help me how to connect to database in C# using WPF and XAML.
My main intention, is connecting to database in WPF.
Thank You,
Ramm
|
|
|
|
|
There are many ways to do this, but the most obvious one would be to use Linq to hook up to the stored proc. This would give you a workable model - then you would hook this data from a view model into your view. It's relatively straightforward, then, to synchronise between two lists so that your sub project is refreshed whenever your projects list changes.
"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
|
|
|
|
|
Hi,
I've googled myself silly with no luck... Using SL3, all I need to do is bind a container control to a List<>, and set the ItemTemplate to my UserControl (easy so far) and then have it display horizontally in columns...
Very easy to do vertically with a ListBox but I need it horizontally...
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|
|
Not quite sure if I understand what you want to do, but couldn't you use a stack panel?
only two letters away from being an asset
|
|
|
|
|
Hi Mark,
Is it possible to bind a StackPanel? I don't see a ItemSource or ItemTemplate attribute either...
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|
|
ItemsControl has an ItemsPanel property. Set ItemsPanel to a template
containing a StackPanel with its orientation set to Horizontal.
There's an example in the ItemsControl.ItemsPanel Property docs[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark, thanks for the reply, will give it a try
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|
|
Ok, took some googling but got it, for any n00b like me who's going to read this, here's the XAML code:
<ItemsControl ItemsSource="{Binding Path=Columns}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" >
<SNeSControls:ActiveInfonMachineColumn Width="80"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|
|
Hi
I am trying to achieve tricky binding behaviour from a treeview. I have a hierarchy of objects with the same base type. Some of these objects are of a derived 'leaf' type. I want to display the object hierarchy in a tree view with the leaf objects having a different data template from the rest of the branch objects.
The tricky thing I want to achieve is for the treeview to ignore all branches that do not have leaf objects in their subtree e.g. in this hierarhcy:
item1 - item3
_____- item4 - item6 - leaf1
__________________- leaf2
____________- item7
item3 and item7 would not be displayed as they have no leaves in their subtree.
Can this be achieved in XAML?
Thanks
Dan
|
|
|
|
|
I suggest you do that in MVVM. Here is an excellent article[^] describing how to use MVVM with a TreeView.
Eslam Afifi
|
|
|
|
|
I have taken your advice and written a view model layer which wraps my objects. However, I still have a problem:
All of the child lists of my underlying node objects are observable i.e. children can be added or removed at any time and the treeview needs to update. This means that a previously leafless node may suddenly gain a leaf in its subtree and so need to become visible. This means that I cannot simply cull leafless branches of the view model node tree - they need to be present but invisible in the tree view until a leaf is added. I have added a property 'HasLeavesInSubtree' to each tree node view model but have no idea how to use this in XAML to turn the display of these nodes on and off.
Thanks
Dan
|
|
|
|
|
Use a DataTrigger and set the visibility based on this.
"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
|
|
|
|
|
Hi ,
I added <Image> // included an image in the window.</Image>
If I wish to add a label just below the image and few other controls, how can i do it? The XAML Code is shown here.
<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="Auto" Width="Auto" Loaded="Window_Loaded" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
<Image
Name="imgClientPhoto"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Width="auto"
Height="auto"
Grid.Column="0"
Grid.Row="0"
Margin="0" Source="D:\pic1.gif" MinWidth="450" MinHeight="100" Grid.IsSharedSizeScope="True">
</Image>
<Label>
</Label>
</Window>
I added <Label></Label>just below the <Image>
but an error is seen "The property "content" is set more than once.
Please help me to correct this error.
My intention is to add an image at the top(title), then below it a label,then a dropdown box, treeview.. so on..
Please help the good way to work on this.
Thanks Ramm
|
|
|
|
|
You need to put a container into your window to handle multiple items - effectively, the content of your window is the image and you have added extra items immediately after. There are many containers available, e.g. Grid, StackPanel, UniformGrid and so on. The one you use is based on how you want to lay out your interface.
"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
|
|
|
|
|
HI ALL
I was considering and trying to Import sophisticated Designs as Xaml in a Project of WPF
I was Working with AI and also Tried MS Expression Design
==========
1) about AI
I tried to use a Plug-in to export Xaml files, but when you have complicated images it just change that image to a simple image , I had a 3D effect on my Design , but it was simplified by the plug-in i used
and just a very simple image had been made
==========
2) about Expression Design
It didn't have any Effect, the only thing that you have is Gradient, as I saw
and it is not enough to have a professional design
=============
Conclusion: I think The Xaml or at least Xaml Generator are not that powerful to produce complicated, professional designs
================
I want to tell me if it is really rigt or wrong
and if I had mistake in part 1 and/or 2 tell me if there are other tools, plug-ins , and etc
Thank you
Am I banned to write message?
Does anybody see my post?
or is there any problem that I don't get any answer?
modified on Wednesday, July 15, 2009 5:28 AM
|
|
|
|
|
cppwxwidgetsss wrote: I tried to use a Plug-in to export Xaml files, but when you have complicated images it just change that image to a simple image , I had a 3D effect on my Design , but it was simplified by the plug-in i used
and just a very simple image had been made
Expression imports AI files. You need to break them into components to create controls. It doesn't just magically create UI for you. Also, by default it creates a PNG, not XAML, and you should play with the options to create XAML as you need it.
cppwxwidgetsss wrote: It didn't have any Effect, the only thing that you have is Gradient, as I saw
and it is not enough to have a professional design
Expression creates XAML, XAML has gradients, what other effects were you hoping for ?
cppwxwidgetsss wrote: I think The Xaml or at least Xaml Generator are not that powerful to produce complicated, professional designs
A professional design should not be complicated. I've written several programs with WPF, and the UIs on them all are excellent. We had a graphic designer create designs for us in AI, and for one program I skinned with bitmaps, but nowadays I export XAML from AI files. Our designer is given total freedom, which is often a lot of work for me, in terms of non standard shapes etc, but I have NEVER had any trouble turning his screenshots into UI that is identical or better.
cppwxwidgetsss wrote: Am I banned to write message?
Does anybody see my post?
or is there any problem that I don't get any answer?
It's a free website and you posted while the USA ( where most users are ) was asleep. If I was home in Australia, you'd have got a reply. It's now 6 am and I am up early. If you want instant answers, find someone in your timezone you can pay to be on call. Otherwise, you just have to wait until someone replies.
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.
|
|
|
|
|
cppwxwidgetsss wrote: Am I banned to write message?
Unfortunately, no...
cppwxwidgetsss wrote: Does anybody see my post?
Unfortunately, yes.
BTW, set the right country in your profile. It's REAL obvious you're not from the US.
As to your question, you can do pretty much anything you can dream up with WPF. You just have to learn how, and there are no shortcuts in the learning process.
"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
|
|
|
|
|
cppwxwidgetsss wrote: Conclusion: I think The Xaml or at least Xaml Generator are not that powerful to produce complicated, professional designs
That is not correct - WPF allows you to produce extremely professional designs, perhaps it's your lack of artistic ability that's getting in the way.
"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
|
|
|
|
|
Pete O'Hanlon wrote: perhaps it's your lack of artistic ability that's getting in the way.
LOL - as I said, we have a graphic designer, if we didn't, that would sure be our main problem....
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.
|
|
|
|
|
cppwxwidgetsss wrote: I want to tell me if it is really rigt or wrong
I'm going with wrong.
XAML and XAML generators do NOT produce "complicated, professional designs"...designers do.
In fact, nothing in your post has anything to do with XAML...
You may want to try out Expression Blend 3[^], which supposedly now imports
PSD/AI files preserving the layers and allowing editing in Blend.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|