|
While you could do this, you really are defeating the purpose of binding in WPF here. It's a whole different beast to what you got with WinForms and ASP.NET - it's far more powerful. Here[^], I demonstrate binding in ASP.NET, versus WPF to demonstrate binding at a very basic level. If you follow my blog links, I talk about binding in more detail.
|
|
|
|
|
Pete O'Hanlon wrote: you really are defeating the purpose of binding in WPF
Yeah, that's what I thought, I must admit I'm all about the data, and battleshit gray screens are just fine by me. Ah well, every thing changes I guess.
If I pursue this, at least there seems to be plenty of quality resource here, thanks
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
To be fair though, battleshit gray doesn't cut it any more ... at least from a users point of view.
|
|
|
|
|
Jammer wrote: doesn't cut it any more
true, I had a junior dev go through an app and prettify it by adding some colours, the users thought it was a MUCH better app, no change in functionality just added some color. I dunno whats the world coming to when a splash of color defines the quality of the app.
Ah yes I almost forgot, bah humbug, after all it is the season.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hehe ... I see the same thing happening with apps I'm currently working on.
Most end users aren't that passionate about how the app works, just so long as it makes them feel they are in an episode of Star Trek they're happy ...
I'm also happy to oblige!
|
|
|
|
|
After reading your article it seems you should end up with 2 resource type in different places.
1 the dynamic resource of the grid that belongs on the form b/c of it's binding to the data
2 the styles and pretties that reside in a resource (think CSS) that give the app consistency.
I guess it is off to Josh's article to get the details.
Thanks Pete, still not convinced it is valid for LOB apps but as Jammer said the users are starting to expect this level of pretty in their apps.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Have a read through some of Karl's articles on using WPF for LOB apps. They should help to convince you.
|
|
|
|
|
Yeah, started in on the first one, I think I will need to commit to working through them to get involved. Nice that they are focused on LOB stuff.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I can only echo Petes points.
WPF is definitely LOB ready. It's a beast that needs taming in a lot of ways but its so the way forward.
|
|
|
|
|
Hi
How can I get the name of a control ie textblock which is defined in a datatemplate in the xaml when i am in the code page?
Koos
|
|
|
|
|
You give a control a name normally by using x:Name="myControlName" in the control. This control is then available in the Code Behind.
|
|
|
|
|
Hey guys, I read a couple of the articles on here as well as the MSDN Sample for this task however I seem to be stuck; was hoping you guys could help me.
The following is my code, and although the items appear in the list perfectly, the ExpanderHeader appears with no text despite my text binding and I haven't the foggiest idea what I'm doing wrong.
Any help would be greatly appreciated!
<CollectionViewSource x:Key='mrpSource'>
<CollectionViewSource.GroupDescriptions>
<d:PropertyGroupDescription PropertyName="Vendor" />
</CollectionViewSource.GroupDescriptions>
</CollectionViewSource>
<ListView BorderThickness="0" ItemsSource="{Binding Source={StaticResource mrpSource}}" Margin="15,0,25.221,-520" Name="lvMRP" VerticalAlignment="Bottom" Height="494">
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Margin" Value="0,0,0,5"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander IsExpanded="False" BorderBrush="SlateGray" BorderThickness="0,0,0,1">
<Expander.Background>
<RadialGradientBrush>
<RadialGradientBrush.RelativeTransform>
<TransformGroup>
<ScaleTransform ScaleX="1.702" ScaleY="2.243"/>
<SkewTransform AngleX="0" AngleY="0"/>
<RotateTransform Angle="0"/>
<TranslateTransform X="-0.368" Y="-0.152"/>
</TransformGroup>
</RadialGradientBrush.RelativeTransform>
<GradientStop Color="Gainsboro" Offset="0"/>
<GradientStop Color="Cornsilk" Offset="1"/>
</RadialGradientBrush>
</Expander.Background>
<Expander.Header>
<DockPanel>
<TextBlock FontWeight="Bold" Text="{Binding Path=Vendor}" Margin="5,0,0,0"/>
</DockPanel>
</Expander.Header>
<Expander.Content>
<ItemsPresenter />
</Expander.Content>
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</ListView.GroupStyle>
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding Path=CompanyPartNumber}" Width="310" HeaderContainerStyle="{StaticResource colHeaderStyle}">NRC/Jaro Stock#</GridViewColumn>
<GridViewColumn DisplayMemberBinding="{Binding Path=VendorPartNumber}" Width="310" HeaderContainerStyle="{StaticResource colHeaderStyle}">Vendor Stock#</GridViewColumn>
<GridViewColumn DisplayMemberBinding="{Binding Path=CustomerPartNumber}" Width="310" HeaderContainerStyle="{StaticResource colHeaderStyle}">Customer Stock#</GridViewColumn>
</GridView>
</ListView.View>
<ListView.BitmapEffect>
<DropShadowBitmapEffect />
</ListView.BitmapEffect>
</ListView>
Code Behind:
((CollectionViewSource)this.Resources["mrpSource"]).Source = dt_MRPTEST.DefaultView
|
|
|
|
|
Check the output window for any data binding errors. Install Mole and examine the DataContext of the Expander.Header, I often find it useful to add a keypress handler that calls Debugger.Break() when the pause key is pressed.
Some tips on debugging bindings are here.
|
|
|
|
|
Thanks for the tips...it turned out that the grouping passes the grouped data as "Name" rather than it's actual path name so all I had to do was change my binding from "Vendor" to "Name" in the text binding...guess it's just one of those oddities of programming...lol.
Thank you!
|
|
|
|
|
Hi everyone. I might be missing something obvious, but after I run a simple WPF storyboard to animate an object's width, I am no longer able to change the width manually. I have created the simple example below to demonstrate my point. The width change done by the first button works before you animate with the second button, but not after.
What am I missing here? How can I "unfreeze" my width property so I can set it again?
XAML:
<Canvas>
<Button Click="Button_Click">
Set width to 100
</Button>
<Button Canvas.Top="30"
Animate width to 250
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="RedRectangle" Storyboard.TargetProperty="Width" To="250" Duration="0:0:1" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Button.Triggers>
</Button>
<Rectangle Name="RedRectangle" Width="25" Height="25" Canvas.Top="70" Fill="Red" Stroke="Black" />
</Canvas>
C# code behind:
private void Button_Click(object sender, RoutedEventArgs e)
{
RedRectangle.Width = 100;
}
Thanks in advance
Josh Fischer
|
|
|
|
|
Found the answer to my own question: FillBehavior="Stop"
http://msdn.microsoft.com/en-us/library/aa970493.aspx
Josh Fischer
modified on Wednesday, December 10, 2008 10:23 AM
|
|
|
|
|
|
[WPF 3.5 SP1] is there any way to place a DependencyProperty in a base class so that if you have a set of usercontrols (with the same base) and each of those controls acting as a Routed Template and you had a for instance that you were binding a Title DependencyProperty to...
Templates being: XceedSubControl_3D
XceedSubControl_Standard
Since you have to have specify [typeof(XceedSubControl)] when the DependencyProperty is registered...and each of your templates have a different name how would you go about this? The DependencyProperty itself compiles fine but binding fails.
public class SubControlBase : UserControl { public static DependencyProperty TitleProperty = DependencyProperty.Register( "Title", typeof(String), typeof(XceedSubControl),
Thoughts or insights would be appreciated.
|
|
|
|
|
hi evrybody
i try to do task by WPF for trying the work with WPF enviroment
i try to add combobox in gridview but i dont know how can i bind or fill combobox in xaml
i wrote this but not enough
<ListView Width="Auto" ItemsSource="{Binding}" Height="Auto" IsSynchronizedWithCurrentItem="True">
<ListView.View>
<GridView>
<GridViewColumn Header="Gender ID" Width="120">
<GridViewColumn.CellTemplate>
<DataTemplate >
<TextBox Margin="0,0,0,0" Text="{Binding Path=GenderID}" Width="100"></TextBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Gender Type" Width="120">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ComboBox Name="Combo_Type" ItemsSource="{Binding Source={}" DisplayMemberPath="{Binding Path=GenderType}" Width="100"></ComboBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
MD_NADA
|
|
|
|
|
It sounds like you want to use an enum for the items source of your combobox, so this article should be a good starting point. You will probably want to bind SelectedItem="{Binding Path=GenderType}" instead of DisplayMemberPath.
|
|
|
|
|
thanks for reply
but this not working
in fact the GridView Bind to CollectionView and i want to fill the combobox in GridView by the binding to anothet table , i know how can i do this in windows forms but in WPF i see i can set binding in xaml
i hope i show this point clearly
MD_NADA
|
|
|
|
|
Hi!
I need to implement a few UserControls in WPF. Since they all have some common functionality I want to create a base class from which they would all derive. The problem is that UserControl has to extend the UserControl class and there is no multiple inheritance in c#. Does anybody know a good way around this problem? Every advice will be appreciated!
Uros Bregar
|
|
|
|
|
You just use an inheritance chain
Create your base class inheriting from the UserControl class
MyBaseControl : UserControl
Then your control inherits from your base class, simple (If I understood the question correctly
ActualControl : MyBaseControl
|
|
|
|
|
I guess i didn't explain my problem well enough. When you create a user control in visual studio, you actually get three files. .cs, .xaml and .g.cs(when using xaml and c#). When you change the base class of the partial class defined in .cs file, you have to do the same for the class defined in the .g.cs file, since partial classes have to have the same base class. The problem is that the .g.cs file is auto-generated by VS and gets changed every time the content of the xaml file is re-compiled.
Uros Bregar
|
|
|
|
|
Is this what you're looking for?
namespace MyNamespace
{
public partial class MyUserControlBase : UserControl
{
public MyUserControlBase()
{
}
}
public partial class MyUserControl : MyUserControlBase
{
public MyUserControl()
{
InitializeComponent();
}
}
}
<local:MyUserControlBase x:Class="MyNamespace.MyUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MyNamespace"
Height="300" Width="300">
<Grid>
</Grid>
</local:MyUserControlBase>
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|