|
Soulus83 wrote: a couple of CPians that I don't know why are there
I have compromising photos of Josh Smith using an iPad.
|
|
|
|
|
If you're already comfortable in .NET programming (C# or VB) then I would (and did) read through the entire SDK documentation. Then do it again.
Windows Presentation Foundation[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I'm working on a new project, so I'm going w/ MVVM from the ground up... trying to stick to 100% "proper" MVVM and deleting the code behinds (and the subsequent InitializeComponent() call)... seems like this works fine for windows & dialogs, but seems to be an issue for a UserControl. Is it possible to have a UserControl without calling InitializeComponent()? I have an attached property on the usercontrol.xaml for the viewlocator, but even that is not getting called.
|
|
|
|
|
SledgeHammer01 wrote: trying to stick to 100% "proper" MVVM and deleting the code behinds
That's not a requirement of MVVM, and nor should it be. InitializeComponent is a very important method call.
I don't know where this zero-code-behind idea comes from. All MVVM requires is that you don't put model code in the code-behind. It's still acceptable to have a code behind, where you might want to trigger an animation for instance.
|
|
|
|
|
Well, kind of silly to have two code files if you don't need to . I mean, having view.xaml, view.xaml.cs, viewmodel.cs. I realize view.xaml.cs != viewmodel.cs (by theory only), but it seems silly to have it just for a constructor & initalizecomponent or to split code across two files.
I was trying to play around with an attached behavior to do this, but it seems like InitializeComponent() is not even a real function, its just generated in the g.cs file (sometimes) and the URI for the view is hard coded
P.S. Microsoft triggers animations via bool DependenyProperties. They don't even use StoryBoards. That seems pretty weird all the control animations are done via code.
|
|
|
|
|
Well, the idea, IIRC, is to have separated logic for Presentation(View) and Logic (ViewModel), so you can easily test Logic without having to simulate user clicks....that's only one of the main benefits...
Also, it's easily to port your ViewModel-Model to another View( ASP.Net MVC, a WCF service, etc) as you'll only refactor the view part.
If you think you're building something simple, then use the usual way, having code on the view and that stuff, I mean, MVVM is there to help, not to bloat your projects, just use what fits your needs
"Whether you think you can, or you think you can't--either way, you are right." — Henry Ford
"When I waste my time, I only use the best, Code Project...don't leave home without it." — Slacker007
|
|
|
|
|
Yeah, I got it working an attached property that calls InitializeComponent() for me. That lets me avoid the dummy (at this point) code behind. My new project is kind of cool as I have all sorts of time to experiment with stuff like this . Gotta love no deadlines.
|
|
|
|
|
Remember that your .xaml.cs class is a partial class. The .g.cs class is the other half of the partial class, and it's generated to hook into baml - hence, it's kind of important to have the InitializeComponent in there.
|
|
|
|
|
SledgeHammer01 wrote: InitializeComponent
This needs to be called. SO you wont be able to remove it.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
hello guys... I have three tabs on which some of the GUI is same. So when I was done with tab1, I simple copied the some of the code in tab2, but off course changing some of the values and thier coordinates. But this act shows me above mentioned exception? Here is some of the code I copied.
<groupbox:GroupBox Header="Batch Details" Height="120" Width="430" Margin="0,10,800,0" >
<StackPanel>
<sdk:Label Height="28" Name="lblBatch" Width="50" Content="Batch Id:" Margin="-75,0,300,0"/>
<TextBox Height="20" Width="90" Margin="-130,-30,100,0" Name="txtBatch"></TextBox>
<sdk:Label Height="28" Name="lblCreatedBy" Width="65" Content="Created By:" Margin="-70,-30,0,0" />
<TextBox Height="20" Width="120" Margin="117,-30,0,0" Name="txtCreatedBy"></TextBox>
<TextBlock Height="20" Width="75" Margin="320,-27,0,0" Name="txtblkDate" Foreground="Blue">2011-05-12</TextBlock>
<sdk:Label Name="lblOperator" Height="28" Width="55" Margin="-365,0,0,0" Content="Operator:"></sdk:Label>
<TextBox Height="20" Width="100" Margin="-210,-25,0,0" Name="txtOperatorVal" IsReadOnly="True"></TextBox>
<TextBox Height="20" Width="240" Margin="140,-25,0,0" Name="txtOperatorVal2" IsReadOnly="True"></TextBox>
<sdk:Label Content="Approval: " Height="28" Width="55" Margin="-360,0,0,0"></sdk:Label>
<TextBox Height="20" Width="240" Margin="-65,-25,0,0" Name="txtApproval" IsReadOnly="True"></TextBox>
<TextBox Height="20" Width="100" Margin="285,-25,0,0" Name="txtApproval2" IsReadOnly="True"></TextBox>
</StackPanel>
</groupbox:GroupBox>
<groupbox:GroupBox Header="Batch Details " Height="120" Width="430" Margin="0,10,800,0">
<StackPanel>
<sdk:Label Height="28" Name="lblBatchOpr" Width="50" Content="Batch Id:" Margin="-75,0,300,0"/>
<TextBox Height="20" Width="90" Margin="-130,-30,100,0" Name="txtBatchOpr"></TextBox>
<sdk:Label Height="28" Name="lblCreatedByOpr" Width="65" Content="Created By:" Margin="-70,-30,0,0" />
<TextBox Height="20" Width="120" Margin="117,-30,0,0" Name="txtCreatedByOpr"></TextBox>
<TextBlock Height="20" Width="75" Margin="320,-27,0,0" Name="txtblkDateOpr" Foreground="Blue">2011-05-12</TextBlock>
<sdk:Label Name="lblOperatorOpr" Height="28" Width="55" Margin="-365,0,0,0" Content="Operator:"></sdk:Label>
<TextBox Height="20" Width="100" Margin="-210,-25,0,0" Name="txtOperatorValOpr" IsReadOnly="True"></TextBox>
<TextBox Height="20" Width="240" Margin="140,-25,0,0" Name="txtOperatorVal2Opr" IsReadOnly="True"></TextBox>
<sdk:Label Content="Approval: " Height="28" Width="55" Margin="-360,0,0,0"></sdk:Label>
<TextBox Height="20" Width="240" Margin="-65,-25,0,0" Name="txtApprovalOpr" IsReadOnly="True"></TextBox>
<TextBox Height="20" Width="100" Margin="285,-25,0,0" Name="txtApproval2Opr" IsReadOnly="True"></TextBox>
</StackPanel>
</groupbox:GroupBox>
So on tab2, it shows me a NullReferenceException thrown on GroupBox. Whats wrong? thnx
|
|
|
|
|
No idea with that wall of text lol. Two ways to go about fixing it: 1) turn on first chance exceptions and see if you get any further info 2) delete tab2 and add the controls back one by one til you see which one is throwing.
|
|
|
|
|
I would assume that the null reference is actually being thrown by one of the fields you are using to fill the TextBox es.
|
|
|
|
|
Hi,
trying to create a custom control derived from DataGrid.
At this point I want to have the same fuctionalaty as DataGrid.
I created A Custom Control derived from DataGrid:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace ZivControls
{
public class ZivGrid : DataGrid
{
static ZivGrid()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(ZivGrid), new FrameworkPropertyMetadata(typeof(ZivGrid)));
}
}
}
Can someone please write the Generic.xaml so that the new custom control will have the same fuctionalaty as DataGrid (improving the control is my next step).
Thanks
Nitsan
|
|
|
|
|
You already have the same functionality as the DataGrid.
I believe you can find the XAML template for the base classes on MSDN. If you want to modify the style, start from there. The DataGrid template is (obviously) pretty complex, no-one is going to modify it in exactly the way you want except you. Get to it.
|
|
|
|
|
I already have the default style (very difficult task for it self) of the Datagrid. But when you set (with changes to the new object name) it as the generic.xaml of the new control it is a mess.
As a Delphi programer who use to derive class so simply, I am so disappinted how dificult it is to derive the Datagrid class.
|
|
|
|
|
Why do you feel the need to derive from it? One of the principles behind WPF and Silverlight is that you have new ways to extend the controls without having to extend it. 9 times out of 10, when somebody attempts to derive a control it simply means that they aren't aware of a simple way to extend it.
If you tell us what you are trying to achieve, we may be able to help.
|
|
|
|
|
Hi,
I want to have a TextBox above the DataGrid that will be used for incremental search on the selected field in the DataGrid. This feuture must be built-in the grid control.
|
|
|
|
|
Why must the TextBox be built into the grid control? You could simply host your DataGrid inside a Grid with two rows, and set the first row to contain the TextBox.
|
|
|
|
|
The incremental search (which is one example) is a must for every datagrid in my applications and I use a lot of datagids some are created by code in runtime so you don't want to create the textbox and write all the code to do the search every time.
The most important thing in deriving the datagrid which is a very important control in my application is the ability to improve the datagrid all the time and all your applications get the benefit from it withot chaging your source code.
|
|
|
|
|
So just wrap it in a UserControl and use that. Seriously, you'll save a lot of heartache and effort over retemplating the DataGrid.
|
|
|
|
|
When wraping to User Control you are losing all the DataGrid design time properities and events. If there was an easy way to expose all the DataGrid properties then User Control will be graet.
|
|
|
|
|
Then you're on your own mate. We've tried to offer practical ways around this, but if you're absolutely set on retemplating then fly at it. You can download the DataGrid template from Microsoft.
|
|
|
|
|
|
I'm not sold on Silverlight/WPF's approach to controls, either, to be honest. Inheriting from WinForms controls is more comparable to Delphi and I find it nicer, in general.
|
|
|
|
|
hello guys... I am having difficult time and am unable to find the panel control (in Silverlight) inwhich we can group some of the controls (like labels, textboxes and buttons) and then name that group in top left corner of that panel. How to get/add/find that control and add on the silverlight app? thnx
|
|
|
|
|