|
I reckon the answer is in here[^].
|
|
|
|
|
I'm working on a WFP/MVVM app that hast portions that need to run on a Windows 8 tablet.
Some parts of the app are not responding to touch. Buttons do, but grid row selection and other controls do not.
I'm brand new to working with touch. My understanding is that if you don't handle the touch event, it's promoted to a click.
I can trap Touch Down/Up in the code behind. But that doesn't help with my Grid.SelectedItem in an MVVM environment.
Anyone have any experience here that can point me in the right direction?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
Did you use ManipulationStarted & ManipulationCompleted event?. Try this once.
|
|
|
|
|
How do you create a data grid in WPF with multiple bands? I can't find a single example
If it's not broken, fix it until it is
|
|
|
|
|
|
Wonderful.
I'll use 2 grids.
If it's not broken, fix it until it is
|
|
|
|
|
A number of third party tools like Telerik, Infragisitcs provide nested grid s that you could explore for your implementation.
|
|
|
|
|
Hello,
I have the next view XAML file:
<Grid>
<ScrollViewer>
<ItemsControl ItemsSource="{Binding MemControls}"/>
</ScrollViewer>
</Grid>
The ItemsControl binded to:
public ObservableCollection<UserControl> MemControls
{
get { return _memControls; }
set { _memControls = value; }
}
in the view Model.
I want to give the user an option to save GUI configuration. So when he press "Save" button i want to serialize the:
public ObservableCollection<UserControl> MemControls
<pre>
to XML file and when he want to restore GUI configuration i want to to desirialize from an XML file the list of controls and that way to restore GUI configuration.
How can i do it?
Maybe there is some other better way that dont involve XML files?
Thanks
|
|
|
|
|
Although this article [^]is for winforms it may give you some ideas.
I would also check out the comment from Tom Clement and see if he did an article on FormEx.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
Hello Listeners,
I created a SL application (using C#) that returns contents of a table in SQL database. Table has 5 columns (FirstName, LastName, Age..etc).
--A grid is populated with following:
EclipseMTXDomainContext context = new EclipseMTXDomainContext();
dataGrid1.ItemsSource = context.DBTables;
context.Load(context.GetDBTablesQuery());
--Mine domain service has an entry as follows:
public IQueryable<dbtable> GetDBTablesCompare() {
return this.ObjectContext.DBTables;
}
This works fine but
What I am trying to do now is load only two columns at a time so I added this in the domain services
public IQueryable<dbtable> GetTwoColms(string db1,string db2) {
return this.ObjectContext.DBTables.Where(P => P.col1Name == cl1 && P.col2Name == cl2);
}
--And the main program, added this to a button action
EclipseMTXDomainContext context = new EclipseMTXDomainContext();
dataGrid1.ItemsSource = context.DBTables;
context.Load(context. GetTwoColms Query("LastNames","FirstName"));
It does not fail but it does not return anything either.
Any help is greatly appreciated
|
|
|
|
|
My first guess:
You have the column names as "LastNames" (plural) and "FirstName" (singular) which looks suspiciously like a typo.
|
|
|
|
|
ThanX Matt,
that is not the issue, it is just careless type when creating the post.
|
|
|
|
|
picasso2 wrote: it is just careless type when creating the post. Then use Copy & Paste, so what we see here matches exactly with what you have in your program.
Veni, vidi, abiit domum
|
|
|
|
|
u can use lamda method select() return a implicit class consists of u wanted 2 columns
|
|
|
|
|
Hi all
below is my wpf progress bar
Dim duration As New Duration(TimeSpan.FromSeconds(20))
Dim doubleanimation As New DoubleAnimation(200.0, duration)
PBar.BeginAnimation(ProgressBar.ValueProperty, doubleanimation)
Now please tell me how to open a window after the progress bar load complete..
|
|
|
|
|
Subscribe to the Completed event[^] on your DoubleAnimation[^] instance, and open the window when the event is raised.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
5ed!
--
If money is your hope for independence, you cannot reach it.
Being loved gives you strength,
while loving gives you courage.
|
|
|
|
|
I am still struggling to understand how to use DP's....
I am designing a Job Picker control[^]. The control is housed inside a Select Job window and also inside a wizard. When the user clicks a Job, I want that job exposed as a DP so the Window or Wizard know that a job was selected.
In the Window, when a Job is selected, the Select button will come on.
So in the control there is the tree:
<controls:TreeViewEx BorderThickness="0"
Margin="5"
ItemsSource="{Binding Jobs}"
SelectedItemEx="{Binding SelectedJob, Mode=TwoWay}"
IsManipulationEnabled ="True"/>
It's bound to Jobs and has it's SelectedItem bound to SelectedJob:
The JobListControl's VM is JobListViewModel:
#region Bound Properties
private ObservableCollection<JobSummaryModel> _Jobs;
public ObservableCollection<JobSummaryModel> Jobs
{
get { return _Jobs; }
set
{
if (_Jobs == value)
return;
_Jobs = value;
RaisePropertyChanged("Jobs");
}
}
private JobSummaryModel _SelectedJob;
public JobSummaryModel SelectedJob
{
get { return _SelectedJob; }
set
{
if (_SelectedJob == value)
return;
_SelectedJob = value;
RaisePropertyChanged("SelectedJob");
}
}
#endregion
This all works fine. When I click a Job in the tree, the SelectedJob property fires. So far so good.
Now, I need to expose the SelectedJob to the control's host (either the SelectJob window or the Wizard). So I went into the code behind and added a DP:
public partial class JobListView : UserControl
{
public JobListView()
{
InitializeComponent();
}
#region SelectedJob DP
public JobSummaryModel SelectedJob
{
get { return (JobSummaryModel)GetValue(SelectedJobProperty); }
set { SetValue(SelectedJobProperty, value); }
}
public static readonly DependencyProperty SelectedJobProperty = DependencyProperty.Register("SelectedJob", typeof(JobSummaryModel),
typeof(JobListView));
#endregion
}
Next, in the Window's XAML I have:
<views:JobListView Grid.Row="0"
SelectedJob="{Binding Path=SelectedJob, Mode=TwoWay}"/>
The SelectJobWindowViewModel has a SelectedJob property of the same type as the JobListViewModel above;
The SelectJobWindowViewModel.SelectedJob property never fires.
I guess I was expecting the DP to pass the Selected Job from the control through to the Window.
Wat am I not seeing here?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
First of all your property should be static, like this;
public static JobSummaryModel SelectedJob
|
|
|
|
|
I tried it, but it won't compile. I get
An object reference is required for the non-static field, method, or property 'System.Windows.DependencyObject.SetValue(System.Windows.DependencyProperty, object)'
Same on the getter.
If it's not broken, fix it until it is
|
|
|
|
|
Pete must have been smoking some really good dope when he answered you . Your code is correct how you have it. I'm assuming you got rid of the:
private JobSummaryModel _SelectedJob;
public JobSummaryModel SelectedJob
{
get { return _SelectedJob; }
set
{
if (_SelectedJob == value)
return;
_SelectedJob = value;
RaisePropertyChanged("SelectedJob");
}
}
stuff and REPLACED it with:
public JobSummaryModel SelectedJob
{
get { return (JobSummaryModel)GetValue(SelectedJobProperty); }
set { SetValue(SelectedJobProperty, value); }
}
public static readonly DependencyProperty SelectedJobProperty = DependencyProperty.Register("SelectedJob", typeof(JobSummaryModel),
typeof(JobListView));
??
The key point here that everybody seems to be forgetting is that DPs don't go through the C# getter / setter (when binding). That is only there to make it easier to get/set the DP from the code. Your SelectedJob method is *COMPLETELY* bypassed by the binding system.
Use one of the DependencyProperty.Register overloads that take a property changed callback. That is the ONLY way you can determine when a DP value changes.
|
|
|
|
|
I thought I read in the OP's first message that he put the DP code in the code behind for the page. We should point out that the DP code and the property should both be defined in the view model. Nothing should be in the code behind!
|
|
|
|
|
First, I don't agree with the "Nothing in the code behind" mantra.
Second, if the DP is in the VM, then how does the control's host see it? It won't.
If it's not broken, fix it until it is
|
|
|
|
|
Whether you agree with it or not, it doesn't change the fact that is the accepted method of implementing MVVM. They aren't called best practices because somebody arbitrarily thinks there shouldn't be code in the code-behind. There are very few instances where code in the code behind is the only option. And putting the DP implementation in the code behind is not one of those times.
Secondly, do you actually know how the DP system works and how the property binding system works? Do you even know why you use dependency properties? Your comments make me think not. The DP system is pubic and static... it is accessible from anywhere in your code. The binding framework knows how to find the DP if the underlying property has been registered with it. Normal developers put the DP code in the view model so it only gets instantiated once. But you probably don't agree with that mantra either.
You seem sure that the control can't see the DP unless it is in the code behind but the dozens of programs I've written in Silverlight, WPF, WinRT, and Windows Phone all seem to work perfectly fine without a single DP in a code behind. And for the life of me, I can't find any real examples of someone suggesting that it goes in the code behind. Clearly I must be doing something wrong...
|
|
|
|