|
I think we need a 'reset', cause I'm a bit lost in our discussion as well .
So:
1. Not, I do not have any problems with code not working, I'm just referring to your statement, that I could throw out XManager from resources.
2. Let's consider such code (pseudo-xaml):
<Window>
<Window.Resources>
<local:XManager x:Key="xManager"/>
</Window.Resources>
<Grid DataContext="{Binding Source={StaticResource xManager}}">
...
<TextBox Text="{Binding Mode=TwoWay, Path=ActiveSession.InputText}" />
</Grid>
</Window>
This is a simplified situation of what I have right now in my code. Referring to your post, I could throw out xManager from resources -> this implies that I create instance of the XManager in the code, fe. in the Window ctor; my question is then, how I could refer to such an instance in XAML in DataContext, and if it's not easy / possible, what's the advantage of throwing out xManager from resources.
Also, inside a code I did something like this:
XManager xMgr;
public MainWindow()
{
InitializeComponent();
xMgr = (XManager)FindResource("xManager");
So basically, I do have a straightforward access to this instance from a code.
|
|
|
|
|
Loose the resource and all references to it.
Loose the Grid DataContext XAML.
In code (ctor or Loaded Event) set Window DataContext.
this.DataContext = new xManager;
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Working great, I think I've tried to over-Xaml heh . I can see how this can be useful, altough not in every situation, but still, works fine.
Thank you very much for the support.
|
|
|
|
|
|
Make sure that the chart data source implements change notification. (INotifyCollectionChanged)
That way when you make the chart visible and the collection its bound gets new data it will notify the Chart and it will display.
In WPF or Silverlight you can use the System.Collections.ObjectModel.ObservableCollection(Of T)
modified 27-Feb-21 21:01pm.
|
|
|
|
|
|
You can leave the DependencyProperty.
In order to help, I'll need you to post the code and XAML here.
If you can shrink it down to a small repro of the issue, that would be very helpful.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
If I add an Expander to my Window then when I click the expander in the design window or go into the XAML for the expander the expander will expand. However if I create my own template for the expander as below (it will expand on mouse over), then it does not expand as it did before. How can I get this to happen?
<Style TargetType="{x:Type Expander}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Expander}">
<Border BorderBrush="Black"
BorderThickness="1"
CornerRadius="3">
<Border.Background>
<LinearGradientBrush StartPoint="0.5,0"
EndPoint="0.5,1">
<GradientStop Color="#22FFFFFF" Offset="0" />
<GradientStop Color="#EEFFFFFF" Offset="1" />
</LinearGradientBrush>
</Border.Background>
<HeaderedContentControl>
<HeaderedContentControl.Header>
<TextBlock Text="{TemplateBinding Header}"
Margin="3" />
</HeaderedContentControl.Header>
<ContentPresenter x:Name="myContent"
Visibility="Collapsed" />
</HeaderedContentControl>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter TargetName="myContent" Property="Visibility" Value="Visible" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
|
|
|
|
|
The template you write, replaces the one that was there before. you need to get the original template, and add your bits, without removing the bits that are now missing, as the old template is replaced with this one. I believe Expression will help you find the default XAML for the built in controls, or you can google for it
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.
|
|
|
|
|
In addition to Christian's reply..
Sample templates for many WPF controls are available in the SDK.
Here's the expander template:
Expander ControlTemplate Example[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Ok, having looked at this I realise I did not quite get it right. But it would appear that when I have the Expander selected in Visual Studio the IsExpanded property is set to true which causes it to expand. This behaviour does not seem to exist in Blend. Here I have to right click and select Expand Expander. What is causing this behaviour?
|
|
|
|
|
Hi guys,
I'm about re-planning a larger LOB application (an older version, created as a 2-tier solution is already existing and running for a couple of years). The plan is to go from 2-tier to 3-tier. We are not about to reuse code, so in this regard I'm totally free! Ah yes, it's not a web-application (so no ASP.NET or Silverlight)... Merely Winforms/WPF...
What I am thinking about is whether or not to not make all service directly accessible via a WCF-Service (per class) or going to implement a single Service for communication (call it "CommService" which can send and receive serialized objects) to handle data exchange.
The application relies on several different entities (so I definetly have to implement a couple of WCF-Services when using the one-service-per-entity approach).
What would be the best approach in your opinion?
Greetings,
Stephan Eberle
hawke@deltacity.org
|
|
|
|
|
Hi,
I'd like to derive a DataTable instance from my WPF DataGrid. The DataGrid has a list of objects that make up the datasource for the grid. I need to generate a report from the grid's content. The report unfortunately can't use wpf components as the datasource I'm using telerik reporting and need to send the dataTable as a parameter when creating an instance. Is there an easy way to do this? Even if its not a DataTable and rather some other data structure that reflects the Datagrid's content, that would also work. I don't particularly want to program a function to do this if there is an easier way.
Thanx
|
|
|
|
|
How did you create your datagrid? Do you bind to something like an ObservableCollection? If so, your collection wraps individual instances of items, and you could send this over to the reporting (I'm assuming it supports accepting information from IEnumerable<T> here).
"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
|
|
|
|
|
Yes I used an ObservableCollection<ITenderLineItem> to display my DataSource. The thing is that I'm allowing my user to display certain Items and not others. If I send this collection through to my report, will i be able to create a binding source and set my reports datasource to this collection?
|
|
|
|
|
K. It seems to be working
|
|
|
|
|
Excellent.
"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
|
|
|
|
|
Actually in code behind we can use
canvasname.children.add()
directly
but when using mvvm model through viewmodel
how to access that canvas name from view because i want to add
children to canvas through viewmodel
please explain me how to do that
how to access the layout control from view to viewmodel
|
|
|
|
|
There are a few ways to do based on your requirement.
1. You can create one attached property that you can bind the content of the Canvas to the property of ViewModel.
2. If you are using Prism v2 framework, you can register it as a region and get the access of that region from View Model.
What do you want to add to the Canvas? Can you provide more details about your scenario so that we can help you more easily?
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
Microsoft MVP (Silverlight), WPF/Silverlight Insiders
|
|
|
|
|
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
|
|
|
|