|
Does your converter get called and with the proper values ? I am suspecting databinding problem to the canvas object. Did you see in the output window if you get any databinding errors logged ? I couldn't run your example, it says Annotation does not have a SetValue/GetValue.
Secondly, you might be having a reason, but the scenario you have mentioned would be covered with a normal dependency property, why do you want to make it an attached property ?
|
|
|
|
|
The converter only gets called when the program starts. GetSCOLOR never gets called. The biggest problem is that I don't exactly know how to bind an attached property so I guess that is the problem. I don't get any errors.
Annotation is a control that I wrote to contain graphics (rectangles, circles, ... drawn by the user). That control gets added to a canvas (nsifCanvas) multiple times. Every annotation control has the property SCOLOR (so some can be monochrome and other can contain colors). That is the reason why I use an attached property. When I click on an annotation, that one gets active and depending on the property, a button in a toolbar must be enabled (if the annotation can contain colors) or disabled (monochrome annotation).
Next is a part of the XAML code. In nsifCanvas the user can add Images and also Annotations (the control where the user can add graphics). Everything works except the binding to the attached property.
<Grid>
<DockPanel>
<!-- Add toolbar tray to window -->
<ToolBarTray DockPanel.Dock="Top" Orientation="Horizontal" IsLocked="False">
<!-- tbTools -->
<ToolBar Name="tbTools" Band="1" BandIndex="1">
<Button ToolTip="Edge Color" IsEnabled="{Binding Path=(SCOLOR), ElementName=nsifCanvas, Mode=OneWay, Converter={StaticResource convGraphicColour}}">
<Image Source="Resources\Icons\LineColorHS.png" Style="{StaticResource IconStyle}"/>
</Button>
</ToolBar>
</ToolBarTray>
<!-- Window -->
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
<controls:NSIFCanvas x:Name="nsifCanvas" Background="LightGray">
<!-- Add children in code to populate canvas -->
</controls:NSIFCanvas>
</ScrollViewer>
</DockPanel>
</Grid>
So, I guess I am correct to use an attached property? And if it is correct, does anybody has an example how to bind it? I guess the binding needs to contact the Get function but like I said, the way I do it now, the program doesn't get there. The elementname in the binding is nsifCanvas. nsifCanvas contains the property but the property depends on the annotation control that is a child of that canvas.
I hope someone has an example or something.
Thx
|
|
|
|
|
Ok, here are my thoughts on this.
Pauwels Bart wrote: don't exactly know how to bind an attached property so I guess that is the problem
I think the binding syntax is correct.
"The value which an element has for an attached property is stored by that element, not by the element which exposes the attached property." - Josh Smitt[^]
Relating to your scenario. You would have the SCOLOR attached property in each of the Annotation object. And I am sure that is not what you are expecting ?
What you want is, SCOLOR behave like a "SelectedItem" or "SelectedColor". I would suggest, make a dependency property named "SelectedAnnotation" in your Canvas which will hold the currently selected Annotation object. When an annotation object is selected, set this DP to the selected annotation object.
Bind the button to the SelectedItem property in NFSICanva. Something like this,
IsEnabled="{Binding Path=SelectedAnnotation.SCOLOR , ElementName=nsifCanvas, Mode=OneWay, Converter={StaticResource convGraphicColour}}"
Pauwels Bart wrote: GetSCOLOR never gets called.
Take a look here Debugging dependency properties[^]
|
|
|
|
|
Sorry, I told it wrong. I don't have an attached property in each Annotation object. The attached property is in the nsifCanvas. That was the reason why I used an attached property: every element on the canvas can then have its own value for that property.
Offcourse only the Annotation Control must have that property! Thanks to you I now realise that my solution (an attached property on the nsifCanvas) was not good. Now I have made a normal property in the Annotation control itself (the only control that needs that property).
I allready have a dependency property in nsifCanvas that contains the active element. This is from the type UIElement. The active element can be (at the moment) an image OR an annotation control OR null when noting is selected. Do you maybe know if I can use this property for the binding or do I need to make a new one of the type Annotation? And what do I get when the active element is an image and not an annotation (in this case the buttons also need to be disabled). I guess that when the value of the active element property is "null", the binding will just make the button enabled (null.SCOLOR).
Sorry for the new questions. My normal bindings work perfect but this goes a little bit further and at the moment I'm just a little confused with it all. You have helped me a lot allready, THX ABitSmart!!!
|
|
|
|
|
You can bind to the dependency property directly (instead of DP.SCOLOR) and in your converter you can decide based on the type what should be returned. The converter should be invoked when you set the DP to null also.
Pauwels Bart wrote: THX ABitSmart!!!
Welcome :>
|
|
|
|
|
Offcourse!!!!! So simple! I made it much harder then it was.
Again, thx a lot!
|
|
|
|
|
Hi, from what i know i can use WPF to create browser app using C# code.
My question is , can a WPF application (that is to be viewed from internet browser),be accessed from a central server by many clients over the internet/intranet(intranet is my case),so that users don't need to install the app(except they must have prerequisite .net framework 3/3.5)
I am asking this because i have not learnt ASP.NET yet,so want to see if WPF is better AND future alternative.
-Thanks
|
|
|
|
|
Yes - take a look at ClickOnce deployment.
"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
|
|
|
|
|
Thanks for reply , will look at it now.
|
|
|
|
|
I've been messing around with Silverlight for the last week, trying to get a handle on Prism v2 which was released recently and I had some struggles working with the WCF client proxy generated by Visual Studio. I was trying to use the interface which was generated so I wouldn't have any service dependencies when it was time to write tests. I think the result has been a pretty good implementation, and since I had trouble finding a lot of recommendations on it I wrote a blog post about it. I'd appreciate any feedback as I'm looking to use Silverlight in an upcoming project and I'd like to know if I'm getting things right or if there are some problems I haven't seen yet.
Here's the link to the blog post: http://developmentalmadness.blogspot.com/2009/03/silverlight-and-prism-decoupling-wcf.html[^]
|
|
|
|
|
Hello,
I have a problem with my TreeView not showing the vertical scrollbar correctly. I have plain old TreeView without any kind of style, item template or anything. If I add so many items that they start to appear past the TreeView window, I get a vertical scroll bar. This is pretty standard stuff, I know. But the problem is that the scrollbar itself is strange. Both the up/down scroll bar buttons, which are usually located at the top and bottom of the scrollbar, both appear at the top. Plus, there's no scroll bar thumb between them. I don't know why this is happening. In the design window, the scrollbar is normal.
I just find it strange since my tree view is so basic.
Any ideas?
Thanks!
|
|
|
|
|
Mine just works noraml. Are you setting any styles ?? might be the reason.
|
|
|
|
|
As I mentioned, there are no styles or anything applied to my tree view.
Here's an example as basic as I can make it.
<Window x:Class="TestProject.TestWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window7" Height="119" Width="92"
xmlns:local="clr-namespace:TestProject.Breeze">
<TreeView Name="_treeView1">
<TreeViewItem Header="Employee1 Very Long String">
<TreeViewItem Header="Jesper"/>
<TreeViewItem Header="Aaberg"/>
<TreeViewItem Header="12345"/>
</TreeViewItem>
<TreeViewItem Header="Employee2">
<TreeViewItem Header="Dominik"/>
<TreeViewItem Header="Paiha"/>
<TreeViewItem Header="98765"/>
</TreeViewItem>
</TreeView>
</Window>
I'm absolutely stumped. And it occurs on my collegues' computers as well.
|
|
|
|
|
Do you see the horizontal scrollbar? What happens if you stretch the window horizontally, and then expand the treeview? I've just run your sample and it behaves the way I'd expect it to - you see the small vertical scrollbar because there's a horizontal scrollbar taking up space.
"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
|
|
|
|
|
I fiddled a bit with my code and found the cause, even though I don't really understand why.
My application uses a directx renderer from a DLL that's written in C++. To init the renderer, I pass it the WPF window's hwnd by using WindowInteropHelper. Now the interesting bit: If I init the renderer before creating and showing my modeless dialogs (the ones with the scrollbar problem), the scrollbars don't appear correctly. But if I init the renderer *after* creating the dialogs, the scrollbars are fine.
If anyone has an idea of why this happens, I'd be happy to hear it!
|
|
|
|
|
Hi,
In WPF application I want to fetch collection object and bind that with radio buttons. But I can’t do that directly as there is no property like ItemsSource available for radio button so I researched for it and found one example on below link
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/5137aabc-bb3a-478a-9438-bc93dd9cc0ac/
Example is working fine. But In my project the method that would be invoked has a collection return type and I don’t know what should be the value for ObjectType instead of enum
<objectdataprovider x:key="WindowStyles" methodname="GetValues" xmlns:x="#unknown">
ObjectType="{x:Type sys:Enum}" >
<objectdataprovider.methodparameters>
<x:type typename="WindowStyle">
What value do I need to set for ObjectType="{x:Type sys:Enum}" > property
Thanks & Regards,
Deepak.
|
|
|
|
|
If you want to apply a collection to a radiobutton, then you're better off doing this like this[^] sample.
"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
|
|
|
|
|
Hi,
Can we use navigation in windows. I want to move to anotherwindow on clicking Login button in one window.I also want to store some session values.Ihad done all these in Page. But i want the application window to be small.Hence i want to do it in window.Any idea!
Gomathi R
|
|
|
|
|
GomathiR wrote: Ihad done all these in Page. But i want the application window to be small.Hence i want to do it in window
What do you mean ? What page are you talking about ?
Have you taken a look at the Navigation service feature WPF provides ? See here Link[^]
I have not used it but it seems to be for both standalone and borwser applications.
|
|
|
|
|
You could show your login screen as a modal dialog. WPF is perfectly happy with you displaying dialogs.
"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
|
|
|
|
|
Hi, i am using this method only. But it is applicable for Page navigation only.I want window navigation.
Gomathi R
|
|
|
|
|
GomathiR wrote: But it is applicable for Page navigation only
No it's not. A standard Windows application can show a Dialog. What you could do - and this is a hack, is show the login dialog before you call InitializeComponent(); in the window class. Then, call Application.Shutdown(); if the login fails.
"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
|
|
|
|
|
Thanks Pete. But now i am looking at another serious problem. I am using infra grid in my page. I want to perform edit operation in it. I found a method which works only when "Select *" is used.And also it displays two objects in the grid.
Any idea regarding this.very urgent
Gomathi R
|
|
|
|
|
I don't use the Infra grid, so I can't help you on this. If you can't figure it out, you should raise this on the Infragistics support forums - they are the best place to figure vendor specific issues out.
"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
|
|
|
|
|
please send some sample project for Role-base authorization i.e secure login page with roles ...
thanks in advance..
Ramkumar(senior pgmr)
|
|
|
|