datacontext

UserControl's Resources as UserControl's DataContext?

房东的猫 提交于 2019-12-12 03:14:42
问题 Is it possible to give UserControl's Resources(Or one of its resource) as UserControl's DataContext? I tried to bind a Button's Command Property in a DataGrid's CellTemplate to a property in my ViewModel. If it were use a ListBox instead of DataGrid this works for me such as below, <ListBox.ItemTemplate> <DataTemplate> <HyperlinkButton Content="{Binding DESCRIPTION}" Command="{Binding DataContext.SelectSingleBackCommand, ElementName=LayoutRoot}"/> </StackPanel> </DataTemplate> </ListBox

How to store entities context query object into generic list?

为君一笑 提交于 2019-12-12 03:03:51
问题 In my last question, i successfully to dump the data into combo box with solution from Leo but now, i want to get everything of specific user and store into generic list. i tried with this code but it's not working. May i know is there something wrong with my code ? var contexti = new OrganizationContext(); //contexti.Load(contexti.GetAdminPassQuery(userName), LoadInfo, null); EntityQuery query = contexti.GetAdminPassQuery(userName); contexti.Load<tblAdmin>(query).Completed += (sender, args)

Can't access datacontext of parent

淺唱寂寞╮ 提交于 2019-12-12 02:56:08
问题 Basically what i have is a ListBox with ContextMenu <ListBox Margin="2,0,0,0" Grid.Row="1" ItemsSource="{Binding MyCollection}"> <ListBox.ItemTemplate> <DataTemplate> <Button Style="{StaticResource NoVisualButton }" Tag="{Binding ID}" Width="430" toolkit:TiltEffect.IsTiltEnabled="True" Margin="0,0,0,12" Click="OnSelectWorkOutItemClick"> <StackPanel> <toolkit:ContextMenuService.ContextMenu> <toolkit:ContextMenu> <toolkit:MenuItem Header="delete" Tag="{Binding ID}" Click=

MVC2.NET pass object from viewmodel to view and access it

♀尐吖头ヾ 提交于 2019-12-12 01:32:33
问题 When working with Viewmodels from linq to sql I have an architectural problem. When you have an object from your db (let's say "person"), and you load it in your viewmodel. After this in your view, when you try to acces referenced classes (let's say a person has children object which is a different table in db, and a different datacontext object). You get a "cannot access disposed datacontext object (or something) which is logical, because you loaded your object and disposed the datacontext.

DbLinq - Cache problem

社会主义新天地 提交于 2019-12-12 01:15:02
问题 I'm using linq to sql for MySql (using DbLinq) in an ASP.NET MVC website. I have a weird caching problem. Consider the following methods in my Repository class: public IEnumerable<Message> GetInbox(int userId) { using(MyDataContext repo = new MyDataContext(new MySqlConnection("[Connectionstring]"))) { return repo.Messages.Where(m => m.MessageTo == userId); } } public IEnumerable<Message> GetOutbox(int userId) { using (MyDataContext repo = new MyDataContext(new MySqlConnection("

How to pass value from one page to another page in the context of data binding?

女生的网名这么多〃 提交于 2019-12-12 01:06:27
问题 I am creating an app where we have a Data Template list of building names and when clicked on say "Thomas Gosnell Hall", it will go to a new page with the TextBlock changed to that of the selected building name "Thomas Gosnell Hall". I know data binding is used to do this, but how do I do it across two different pages? MainPage.xaml <TextBlock Tap="TextBlock_Tap" Text="{Binding LineOne}" TextWrapping="NoWrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/> MainPage.xaml.cs (When a user

Using Visibilty with DataContext doesn't work in Button

≡放荡痞女 提交于 2019-12-11 23:42:34
问题 I have a Button where I am trying to add a Visibility attribute which binds to a certain path. In most cases this path will be call and I return a Visibilty(Hidden or Visible). If I have a button that has a DataContext set to a different binded path and try to add the Visiblity stuff, the visibilty binded path never gets called. If I remove the DataContext then the Visibilty works fine. Is there some kind of work around for this? Why does this happen? Thank you very very much. <Button

WPF: UI not being updated with INotifyPropertyChanged

五迷三道 提交于 2019-12-11 21:10:42
问题 I'm currently learning WPF, DataContexts & DataBinding. My goal is to have a Taskbar task (using NotifyIconWpf) that has a continuous thread running the background to monitor a network. I've managed to get a UI element (shown in screenshot) bound to the ProgramClock class, but it does not update when the ProgramClock changes, most likely because something in the INotifyPropertyChanged parameters are wrong. The closest similar problem I've found is UI not being updated INotifyPropertyChanged

DataBinding Between a WPF GUI and a couple of ListBox/CheckBox

落爺英雄遲暮 提交于 2019-12-11 18:23:08
问题 The thing i want to do looks easy, but takes me a lot of time without any result.. =/ I'd like to have a WPF window which takes an object with some proprieties and used it to popolate a couple of item. In the specific the object recieved is so defined: public class ParameterForGraphicOptions { public List<VariablesOptions> Variables { get; set; } public List<string> Simulations { get; set; } public List<string> ShowSimulations { get; set; } } public class VariablesOptions { public string Name

C# WPF two different DataContext in One Control while using MVVM and the secound property is every time the same

故事扮演 提交于 2019-12-11 18:16:43
问题 First the code: <ListView ItemsSource="{Binding DataTransferModel.Output}" Background="Transparent" Margin="0" VerticalContentAlignment="Top" AlternationCount="2" Name="lvOutput" ScrollViewer.VerticalScrollBarVisibility="Auto" Grid.Row="2"> <ListView.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" Margin="0,1"> <UserControls:OutputTextBox Text="{Binding Data, Mode=OneWay}" IsReadOnly="True" Grid.Row="2" TextWrapping="WrapWithOverflow" SelectedValue="{Binding Path=DataContext