i want to implement this
(this application is made in flex)type of application using silverlight, how can i do this? basically i want is to divide xaml page in 3 parts.., on tree view selection change right parts of page should change dynamically.
You could accomplish the loading of multiple xaml files by having multiple navigation frames on a page.
You should be more specific if you want to get answers that fit your needs.
One way to divide the page is using a dockpanel and you get the behaviour that you describe implementing the TreeView SelectedItemChanged event.
Hope hepls!
How to make items in a DockPanel expand to fit all available space in WPF?
Related
My app has a bunch of paragraphs which are compared together. This is implemented using a generic ItemsRepeater that creates as many Grid elements as there are paragraphs. Inside each grid is a TextBlock with the paragraph number, and a RichTextBlock that contains the paragraph. The hierarchy is therefore like this:
<ItemsRepeater>
<Grid>
<TextBlock />
<RichTextBlock></RichTextBlock/>
</Grid>
<Grid>
...
</Grid>
<Grid>
...
</Grid>
</ItemsRepeater>
This results in a text selection as follows:
Only one RichTextBlock can be selected at a time. However, I would like to allow text selection of all paragraphs of the ItemsRepeater. How is that possible?
Edit
I'm open to other approaches. I've tried manually filling in a StackPanel or RichTextBlock with items. That's not a problem. However, because the numbered paragraphs need to align, I need to be able to set their height to match each other. From what I can find, only elements that derive from FrameworkElement have the ActualHeight and Height properties I need for that. However, FrameworkElements like TextBlock and RichTextBlock also do not allow multiple selection, which is the problem I'm trying to solve in the first place. Someone posted a response to a similar question about WPF, but it uses a strange solution I don't think applies.
So the question could also be framed as: how is it possible to find and set the height of a Run within a TextBlock or RichTextBlock? Using that idea, it was impossible to get/set the run height inside a paragraph. I'm not bound to using ItemsRepeater, but that has also not yielded a useful result. I'm seeking to avoid resorting to HTML/Javascript for this.
UWP does not expose enough APIs for you to do that. I have worked on a similar issue with RichEditBox on UWP and there is no good solution that I have found. But if you really want to, there are two main approaches to achieve that:
Implementing the selection yourself by sniffing the mouse events and render the selection on top of the controls. There are so many corner cases, specially if you want to have a proper accessibility tree for the control that you are building.
Alternatively, you can create a WinRT C++ project where you would have access to more APIs, build a control and render it onto a canvas that is created with your C#/Xaml app.
The good news is that you are not permitting people to edit (RichTextEdit) and it is just view (RichTextBlock) so you do not have to worry about the automatic corrections, IME, Url detection, etc.
Edit: Originally I mentioned WinRT C++, but I meant C++/CX. It might work with WinRT too, but I have not tried.
I have a xaml which contains a tab control (Name="MyTabControl"). I'm a beginner with wpf and in code and I want to dynamically add tab items that I then add a list box to each created tab item. Below is the code I have so far.
ListBox listbox = new ListBox()
TabItem tab = new TabItem()
tab.AddChild(listbox)
MyTabControl.Add(tab)
My issue is that I can't figure out how dynamically create new tabs that also would add a list box to each new tab and the new tabs then added to MyTabControl.
Then, I would want to be able to access each list box control, individually, in each tab to edit the list box content.
How is this done in code? How can i access the created list box controls to edit them?
WPF/UWP and XAML are designed with the MVVM pattern in mind. While you can use other approaches, doing so will miss about 90% of it's power and run into issues at every other corner.
In MVVM this would be simply a mater of Exposing a Collection and having a Tempalte targetting that type. ListBoxes might even have a custom Template system, but using ListBoxes might no longer be nessesary - any container can expose a Collection.
If you plan on learning MVVM, mid to longertem you should learn MVVM. I wrote a short intro a few years back, that should help you going. Help for people not following MVVM is parse on the Forum.
In general, it's a violation of the MVVM principles WPF is built around to build a UI in this way. Instead, consider a solution similar to the one proposed in the answers to this question. They do a good job of explaining both what to do, and why we do it this way.
Sorry but I am a newbie to WPF, I would really appreciate if you could help me-
Tag 1 in pic- Which control can I use to create a menu similar to that in the picture ? The closest I came was using a gridview within a listview but that ends up using a header for the gridview. Normal listview just highlights the entire strip and doesn't look good at all.
Tag 2 in pic // (No longer relevant, sorry)
Edit:
Looking for something simple like when using gridview with listview (as in pic below) there is automatically that standard window gradient & bevel effect etc. (As an idea, implementing it with buttons seems to cumbersome, first strip button border, then create all these effects.) So essentially anything already inbuilt in WPF.
Thanks for any help :-D !!!
ListBox or ListView are good controls to use. If it's just the 'pretty' factor you don't like, you can provide Templates to change the appearance. But functionally, ListBox and ListView provide the function of that menu.
When working with WPF, that should be your primary motivation when choose controls. What FUNCTIONS the way you want. You can always make it LOOK different with Templates, but getting the right FUNCTION is the primary goal for the control.
I am creating an App in which I have a menu that will display on every page. The menu contains navigation to another page, so I can avoid repeating the same code on every page and in XAML. How can I change the view of a page without navigating to another page?
Xaml allows you to handle Frames, which are quite like html's iframes :
http://msdn.microsoft.com/fr-fr/library/cc838245(v=vs.95).aspx
some frameworks, like caliburn micro, ease the use of such frames.
Hey Dont know exactly What you want,but according to my understanding you can use Pivot and Panorama control.
This is the best control according to your requirement.
Here is the sample code and description.
http://code.msdn.microsoft.com/wpapps/PanoramaPivot-Sample-332a7e06
So, i have quite complex ListBox, with own style and composite item templates (in every item, there are image and text, both with click events, which rises corresponding commands in global viewmodel). What would be the easiest way to re-use that ListBox?
Should i extract style only, or move it out as UserControl, or should i make new component? Everything is static (commands, markup) exept content (should be able to use different items lists).
In the perfect case, is should be (pseudocode):
Page 1 xaml
<MyListBox Content={Binding Page1List}>
Page 1 vm
ObservableCollection<Items> Page1List;
and so on for other pages.
EDIT: i found this article - that makes sence, but i think there should be easier way for that.
http://www.codeproject.com/Articles/14340/Creating-a-look-less-custom-control-in-WPF
I believe the solution you are looking for is a look-less control.