|
jadughar wrote: My sample is giving error.
At compile time or runtime? I would think that should work too, and it compiles.
jadughar wrote: what's the difference between RoutedEvent and the Event(that u used in ur sample) ??
Routed events are a WPF/Silverlight thing: "A routed event is an event that is potentially passed on (routed) from a child object to each of its successive parent objects in the object tree." The only real difference I saw with your code is you used a RoutedEvent delegate which takes a different eventargs parameter than a simple C# event, which is what I used.
See Events Overview for Silverlight[^]
I only meant I wouldn't use RoutedEvent because RoutedEvents get routed by the framework and that may cause confusion in your code if it's not really an event that gets routed.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i was getting error at run time, no errors while compile time ..
"For as long as men massacre animals, they will kill each other. Indeed, he who sows the seed of murder and pain cannot reap joy and love." Pythagoras
|
|
|
|
|
jadughar wrote: i was getting error at run time, no errors while compile time ..
I'm not going to test it to see the actual error message, but regardless, a RoutedEvent was not what you needed. Just a .NET event.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Ok
thanks for the answer !!!
bye
"For as long as men massacre animals, they will kill each other. Indeed, he who sows the seed of murder and pain cannot reap joy and love." Pythagoras
|
|
|
|
|
I have a DP that I registered as BindsTwoWayByDefault. This works fine if I bind it to property in the VM, but if I bind it to something in the XAML, then it gives me the exception 'Two-way binding requires Path or XPath error'.
if I do:
{Binding SomeProperty}
it works fine, but if I do:
{Binding ElementName=filenameColumn}
then I get that exception. Is there something else I need to do to get the first method to be 2 way by default and the second way to not throw an exception.
I think some of the .NET properties behave that way, in that they are 2 way on the first method, but don't puke on the second method.
I have another DP thats an enum and it doesn't have this issue (I can bind to a property in the VM as well as hard code the enum type in a string), just when the DP type is a class. I register them both the same exact way.
|
|
|
|
|
The issue you are seeing here is that the binding doesn't know what it has to bind to, so if you did {Binding Path=., ElementName=filenameColumn} it should work. Basically, ElementName is not a path so it cannot be used like this, it has nothing to do with whether or not the binding is 2 way.
|
|
|
|
|
Originally the DP was 1-way, so it didn't have this issue and both methods worked fine.
{Binding ElementName=filenameColumn}
This binding DOES work fine (when the DP is one way). The DP was correctly set to filenameColumn. This method:
{Binding SomePropertyInVM}
worked fine as well. Well, sort of. The 2nd method didn't update the property in the VM which is why I made it 2-way. If I change the property back to 1-way, then both methods work again (except for the fact that the 2nd method doesn't update the property in the VM).
What I was saying in my original post was that I don't have this issue with another similiar DP that I changed to 2-way as well. Except that type is a ListViewSortDirection enum and this DP is a GridViewColumn.
So on the other DP, I can do:
TheDP="Ascending" AND TheDP="{Binding SomePropInTheVM}"
if I bind to the prop in the VM, it works fine as 2 way. I guess the first method here isn't using binding, so it doesn't have that issue.
I did try adding a Path=. to the binding as you suggested and it does fix the problem, but I dunno which one is uglier lol:
Having to do this for hard coding in the XAML:
{Binding ElementName=filenameColumn, Path=.}
vs having to do this for MVVM:
{Binding SomePropInTheVM, Mode=TwoWay}
|
|
|
|
|
Meh, I'll just leave it as two-way by default because that'll be the more widely used scenario and let the ElementName people specifically add a Mode=OneWay tag. Thats a little cleaner then Path=. IMHO.
|
|
|
|
|
Hello All,
I have came across below mentioned error message. I dont know why such types issue happens.Anyone can tell me why this issue happens...
Runtime Error 4008... Layout Cycle Detected... Layout Could Not Complete.
Thanks
|
|
|
|
|
This means that you have put too many user controls on the page for the render cycle to complete. It has been upper bounded so that "pathological" (thanks to Microsoft's Rob Relyea for using this term) bounds don't come into play. Basically, the layout has been bounded so that the layout cycle doesn't complete because the layout size is changing.
Rob Relyea has this to say (citing textboxes as an example):
"Layout uses while loops, and the loops need some sort of upper bound on them so that they don’t loop forever in pathological conditions. An example of a pathological condition is if foo’s size is changed in the foo.SizeChanged event handler. There are a number of ways that a layout loop counter can be “used up” legitimately, such as doing anything to invalidate measure during an arrange call, invalidating measure or arrange during a SizeChanged or LayoutUpdated handler (even if a pathological condition is avoided), etc. The TextBox control is doing something to “use up” a layout loop iteration. Since the layout cycle detection is triggered at 250 iterations, under ideal circumstances, you can measure/arrange at most ~250 TextBoxes at once. It has nothing to do with frame rate, the hardware, the browser, etc. It also doesn’t matter how many TextBoxes you have in total, just how many you are laying out in one frame. This is most critical at startup time, when if you have > 250 visible TextBoxes in the tree, you will get a layout cycle. You will also have problems any other time you add > 250 visible TextBoxes, or if you have somehow incrementally added TextBoxes in groups so that you have gotten away with having more than 250, but all TextBoxes layout has been invalidated at once, such as by resizing the browser. You can have as many collapsed TextBoxes on the screen as you want—layout just skips over collapsed controls. Also, if you add the TextBoxes incrementally, and somehow manage them so that they won’t all get invalidated at once (e.g. by putting them in parent containers that won’t ever be resized) you should be OK."
|
|
|
|
|
My goal is to have a *reusable* TreeView control (lets call it MyTreeView) that fills in all the missing pieces of the current WPF TreeView. That is, I want to have out of the box support for images, checkboxes, node lines, etc. When I first started learning WPF, I wrote a MyTreeView control that does exactly this, so I know how to accomplish all that stuff... however, since I was just learning WPF at the time, it wasn't written very well and broke a lot of WPF functionality that I now fully undertand . So its time to rewrite it.
My issue is kind of which way to go with the core design. I know I don't want to give up the HierachialDataTemplate functionality (which I kind of did with v1), but I also know that I would ideally like to rely on the developer for how to get the data ONLY. I do not want the developer to have to deal with setting up the VisualTree. Thats my job.
I always see the HierachialDataTemplates set up like this:
<HierarchicalDataTemplate x:Key="TreeViewItemTemplate" ItemsSource="{Binding Value}">
<TextBlock Text="{Binding Key}" />
</HierarchicalDataTemplate>
That does populate the tree and I would like to keep that functionality, but I'd like to do something where instead of specifying a TextBlock like everybody does, I'd like to have something along the lines of:
<HierarchicalDataTemplate x:Key="TreeViewItemTemplate" ItemsSource="{Binding Value}">
<ItemTextBinding="{Binding Key}" ItemImageBinding="{Binding ImageSource}" ItemIsCheckedBinding="{Binding IsChecked}" />
</HierarchicalDataTemplate>
Doesn't have to be that exact syntax, but you get the idea... instead of specifying the VisualTree, I want to specify how the various UI elements should be data binded (or bound?).
Some issues that I haven't figured out:
1) I can't have attached properties on HierarchicalDataTemplate, so I'd probably have to derive a new class called TreeViewDataTemplate or whatever and force the developer to use that?
2) Doesn't seem possible to set properties on TreeViewItem from within the HierarchicalDataTemplate?
3) the highlight / focus rectangle covers everything in the HierarchicalDataTemplate VisualTree, fine for Vista / Win7 since thats the style, but on XP, thats not the style... the image and checkbox is not included in the highlight rectangle.
If #2 is not possible in anyway, it seems like this idea is kind of dead in the water... I did a similiar thing for ListView, but that had a clean place where the containers are created and I could easily hook into and set up all the data binding... doesn't seem to be the case here.
|
|
|
|
|
Hello,
I have a converted SVG to XAML (by Inkscape). It looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Name="svg2996" Width="42" Height="544">
<Canvas.RenderTransform>
<TranslateTransform X="28.0625" Y=" -217.5"/>
</Canvas.RenderTransform>
<Path Name="path126" Fill="Black" Data="m 10.03125 218.53125 c -1.6395929 0.0966 -3.3798805 1.83194 -6.34375 6.09375 -5.9949892 7.93715 -14.595317 26.52565 -18.03125 36.21875 -5.152605 20.33505 -6.842535 45.06395 -5.125 68.9375 0.841522 7.92825 2.532316 25.58259 5.125 39.71875 4.277456 33.60207 5.15625 47.73889 5.15625 61.875 -0.876011 22.96895 -6.848809 41.50368 -16.3125 53.875 -1.718393 1.76478 -2.5625 3.53295 -2.5625 4.4375 0 0.90455 0.844107 2.67273 2.5625 4.4375 9.463691 12.37132 15.436489 30.89127 16.3125 53 0 14.99638 -0.878794 29.11498 -5.15625 61.8125 -2.592684 15.0407 -4.283478 32.71323 -5.125 39.78125 -1.717535 24.73379 -0.02761 49.47575 5.125 68.90625 4.277456 15.90088 19.751417 43.3125 24.0625 43.3125 1.717534 0 3.4375 -1.78887 3.4375 -3.5625 0 -0.89571 -1.719966 -3.51811 -3.4375 -6.1875 -10.30607232 -14.99633 -14.6262161 -30.03104 -16.34375 -53 0 -14.13615 0.8787945 -27.40216 5.15625 -60.96875 C 0.24878379 623.98719 1.968604 608.08279 2.84375 601.875 6.2796825 559.4755 -0.57292742 523.24857 -17.75 496.75 c -2.593549 -3.53846 -4.3125 -7.0625 -4.3125 -7.0625 0 0 1.718951 -3.55525 4.3125 -7.09375 C -0.57292742 456.09522 6.2796825 419.86657 2.84375 376.5625 1.968604 371.25926 0.24878379 355.37724 -1.46875 341.25 -5.7462055 308.5791 -6.625 295.29239 -6.625 281.15625 c 1.7175339 -22.96897 6.03767768 -38.00367 16.34375 -53 3.435068 -5.30329 4.311289 -7.04771 2.59375 -8.8125 -0.810483 -0.55428 -1.535981 -0.85639 -2.28125 -0.8125 z"/>
</Canvas>
As you can see, all path's coorditates are shifted out of the canvas' bounds and then translated back. Is there an easy (automatic) way to translate all paths Data , so the redutant transform could by removed?
EDIT: I have tried to paste it to Calc and use a formula to add transform's parameter, but I realized that Calc cannot distinguish X and Y in path's Data.
Thanks in advance,
Greetings - Jacek
|
|
|
|
|
The Path's data ends up being a StreamGeometry at runtime and I don't see a direct way to get at its data.
You could try something like this (taken from this link[^]):
PathGeometry geometryTransformed = Geometry.Combine(Geometry.Empty, geometry, GeometryCombineMode.Union, transform);
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
IMHO it's rather a text processing task. After all, I want to alter the XAML to remove Transform declaration. It seems that I will left it as it is and it end up in a hall of shame some day, xor write a script which will make it.
Greetings - Jacek
|
|
|
|
|
Jacek Gajek wrote: IMHO it's rather a text processing task.
At design time, yes. I thought you wanted a runtime way to do it, sorry
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi
I have a four combo boxes, along with one text box and all 5 controls. The principle is that if the user selects an item from the first combo box, this selected item then gets reflected in the text box and the four other combo boxes. Whilst this action is working, if the user then selects a new item from the first combo box, say the next item down in the list, the new item is not showing in the other controls. The previous item is still there and hasn't been refreshed. Checking the class object, when first used, the object is being set with the value, but when selecting a new value from the combo box, this new value is not being passed on or up dates the object. I am using INotifyPropertyChanged!
I have set IsSyncronizeWithCurrentItem ="true" on all of the combo boxes, but this isn't working.
How do you very simply, keep all these controls in sync? Code is being built using MVVM design pattern.
modified on Monday, June 27, 2011 3:53 PM
|
|
|
|
|
IsSynchronizedWithCurrentItem does work. I've used it myself. I won't ask why you have 4 ComboBoxes and a TextBox all showing the same exact info , but if its not working, you're likely doing something wrong, so post your code.
|
|
|
|
|
Check that the binding of the selecteditem in the combobox is Mode="TwoWay" .
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hello guys... I am new to Silverlight. I am trying to create child windows in silverlight but when I try to access some of the methods shown online, those methods are not shows in intellisense. For example
namespace SampleGUIs
{
public partial class MainPage : UserControl
{
private ChildWindow cw;
public MainPage()
{
InitializeComponent();
cw = new ChildWindow();
cw.Closed += new EventHandler(ShowMessage);
}
}
}
I have included System.Windows and System.Windows.Control. Same is the case in ChildWindow.xaml. Some of the methods are not shown like
namespace SilverlightApplication9
{
public partial class PopupWindow : ChildWindow
{
public PopupWindow()
{
InitializeComponent();
this.Title = "Child Window";
}
}
}
what can be the problem? thnx
modified on Monday, June 27, 2011 7:15 AM
|
|
|
|
|
Seems rather obvious, ChildWindow does not have a Title Property whereas UserControl does. It all comes down to what you are deriving your view from.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanx for your answer. It certainly has Title property. I have just solved it. May be I was putting the code in wrong places. But now its working.
|
|
|
|
|
Hi All !
I using DataGrid in WPF and Using DataGrid.RowDetailsTemplate but i only click 1 row .How do I can click more that row in DataGrid?
You can Help me?
Thanks
|
|
|
|
|
There should me a SelectionMode (I think) that can be set to extended.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Using :
<dg:DataGrid AutoGenerateColumns="False"
SelectionMode="Extended"
ItemsSource="{Binding Source={StaticResource FlickrFeed}}"
RowDetailsVisibilityMode="VisibleWhenSelected">
<dg:DataGrid.RowDetailsTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="5">
<Image Source="{Binding XPath=media:thumbnail/@url}"
Width="60" Height="60"/>
<StackPanel Orientation="Vertical" Margin="5">
<TextBlock Foreground="CadetBlue" FontSize="20"
Width="400" TextWrapping="Wrap"
Text="{Binding XPath=media:category}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</dg:DataGrid.RowDetailsTemplate>
but only click a row.i want click more that row.
can you hepl me?
<dg:DataGrid.Columns>
<dg:DataGridTextColumn Header="Title"
Binding="{Binding XPath=title}" Width="150"/>
<dg:DataGridTextColumn Header="Published"
Binding="{Binding XPath=pubDate}"/>
<dg:DataGridTextColumn Header="Author"
Binding="{Binding XPath=media:credit}" Width="*"/>
</dg:DataGrid.Columns>
</dg:DataGrid>
</Grid>
|
|
|
|
|
tâzn wrote: but only click a row.i want click more that row.
hold the <shift> or <ctrl> key when you click the second row
Never underestimate the power of human stupidity
RAH
|
|
|
|
|