Black Friday je tu! Využij jedinečnou příležitost a získej až 80 % znalostí navíc zdarma! Více zde
Hledáme nové posily do ITnetwork týmu. Podívej se na volné pozice a přidej se do nejagilnější firmy na trhu - Více informací.
BF extended 2022

Diskuze: Refresh TreeView v C# WPF mvvm

Aktivity
Avatar
Maros2470
Člen
Avatar
Maros2470:2.3.2021 9:19

Zdravím. Mám problém s obnovením dat v TreeView. Po úpravě, nebo přidání dat dojde ke změně v ObservableCollec­tion i v databázi, ale TreeView data neobnoví.

Zkusil jsem: V MainWindow je obsažen TreeView a Frame. Po SelectedItem se načte Page s detailem vybrané položky v TreeViev. V detailu lze provádět změny, popřípadě vytvářet nové položky. Pro jednoduchost jsem v ukázce kódu ponechal jen Save().

using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace RevizeREVEXplus.Classes
{
    public abstract class BindableBase : INotifyPropertyChanged
    {

        public event PropertyChangedEventHandler PropertyChanged;
        public static event PropertyChangedEventHandler StaticPropertyChanged;

        protected void SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
        {
            if (Equals(storage, value))
            {
                return;
            }

            storage = value;
            OnPropertyChanged(propertyName);
        }
        protected static void OnPropertyChanged([CallerMemberName] string propertyName = null) => StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(propertyName));

        protected void NotifyPropertyChanged([CallerMemberName] string propertyName = "") => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));

    }
}


using Eli_CommandHandler_4_6;
using RevizeREVEXplus.Classes;
using RevizeREVEXplus.DataModels;
using RevizeREVEXplus.Models;
using System.Collections.ObjectModel;
using System.Data.Entity;
using System.Windows.Input;

namespace RevizeREVEXplus.ViewModels
{
    public class BaseViewModel : BindableBase
    {

        public bool _canExecute;

        public BaseViewModel()
        {
            LoadData();
        }

        readonly DataModel context = new DataModel();

        public ObservableCollection<Zakaznik> Zakaznici { get; set; }
        public ObservableCollection<Osoba> Osoby { get; set; }
        public ObservableCollection<Umisteni> Umisteni { get; set; }
        public ObservableCollection<Spotrebic> Spotrebice { get; set; }
        public ObservableCollection<Mereni> Mereni { get; set; }
        public ObservableCollection<SablonaMereni> SablonyMereni { get; set; }
        public ObservableCollection<SablonaVeliciny> SablonyVelicin { get; set; }
        public ObservableCollection<JinaAdresa> JineAdresy { get; set; }
        public ObservableCollection<CenikRevize> CenikRevizi { get; set; }

        public void LoadData()
        {
            context.Zakaznici.Load(); Zakaznici = context.Zakaznici.Local;
            context.Osoby.Load(); Osoby = context.Osoby.Local;
            context.Umisteni.Load(); Umisteni = context.Umisteni.Local;
            context.Spotrebice.Load(); Spotrebice = context.Spotrebice.Local;
            context.Mereni.Load(); Mereni = context.Mereni.Local;
            context.SablonyMereni.Load(); SablonyMereni = context.SablonyMereni.Local;
            context.SablonyVelicin.Load(); SablonyVelicin = context.SablonyVelicin.Local;
            context.JineAdresy.Load(); JineAdresy = context.JineAdresy.Local;
            context.CenikRevizi.Load(); CenikRevizi = context.CenikRevizi.Local;
        }

        // SelectedZakaznik
        private Zakaznik _selectedZakaznik;
        public Zakaznik SelectedZakaznik { get { return _selectedZakaznik; } set { _selectedZakaznik = value; NotifyPropertyChanged(nameof(SelectedZakaznik)); } }
        // SelectedOsoba
        private Osoba _selectedOsoba;
        public Osoba SelectedOsoba { get { return _selectedOsoba; } set { _selectedOsoba = value; NotifyPropertyChanged(nameof(SelectedOsoba)); } }
        // SelectedUmisteni
        private Umisteni _selectedUmisteni;
        public Umisteni SelectedUmisteni { get { return _selectedUmisteni; } set { _selectedUmisteni = value; NotifyPropertyChanged(nameof(SelectedUmisteni)); } }
        // SelectedSpotrebic
        private Spotrebic _selectedSpotrebic;
        public Spotrebic SelectedSpotrebic { get { return _selectedSpotrebic; } set { _selectedSpotrebic = value; NotifyPropertyChanged(nameof(SelectedSpotrebic)); } }
        // SelectedMereni
        private Mereni _selectedMereni;
        public Mereni SelectedMereni { get { return _selectedMereni; } set { _selectedMereni = value; NotifyPropertyChanged(nameof(SelectedMereni)); } }
        // SelectedSablonaVeliciny
        private SablonaVeliciny _selectedSablonaVeliciny;
        public SablonaVeliciny SelectedSSablonaVeliciny { get { return _selectedSablonaVeliciny; } set { _selectedSablonaVeliciny = value; NotifyPropertyChanged(nameof(SelectedSSablonaVeliciny)); } }
        // SelectedSablonaMereni
        private SablonaMereni _selectedSablonaMereni;
        public SablonaMereni SelectedSablonaMereni { get { return _selectedSablonaMereni; } set { _selectedSablonaMereni = value; NotifyPropertyChanged(nameof(SelectedSablonaMereni)); } }
        // SelectedJinaAdresa
        private JinaAdresa _selectedJinaAdresa;
        public JinaAdresa SelectedJinaAdresa { get { return _selectedJinaAdresa; } set { _selectedJinaAdresa = value; NotifyPropertyChanged(nameof(SelectedJinaAdresa)); } }

        private object _frameContent;
        public object FrameContent
        {
            get
            {
                return _frameContent;
            }
            set
            {
                _frameContent = value; NotifyPropertyChanged(nameof(FrameContent));
            }
        }

        private object _treeCustomer;
        public object TreeCustomer
        {
            get
            {
                return _treeCustomer = Zakaznici;
            }
            set
            {
                _treeCustomer = value; NotifyPropertyChanged(nameof(TreeCustomer));
            }
        }

        // Save
        public void Save() => _ = context.SaveChanges();

        public ICommand SaveCommand { get { return new CommandHandler(() => Save(), _canExecute); } }
    }
}


using Eli_CommandHandler_4_6;
using RevizeREVEXplus.Classes;
using RevizeREVEXplus.Views;
using System;
using System.Windows;
using System.Windows.Input;

namespace RevizeREVEXplus.ViewModels
{
    public class CommandViewModel : BaseViewModel
    {
        public CommandViewModel()
        {
            _canExecute = true;
        }

        public static void BackWinPage()
        {
            PageNavigator.GoBack(0);
        }

        //ZakaznikView
        public ICommand ZakaznikCommand { get { return new CommandHandler(() => Zakaznik(), _canExecute); } }
        public static void Zakaznik() { PageNavigator.NavigateToPage(new ZakaznikView(), 0); }


        private WindowState _curWindowState;
        public WindowState CurWindowState
        {
            get
            {
                return _curWindowState;
            }
            set
            {
                _curWindowState = value;
                NotifyPropertyChanged(nameof(CurWindowState));
            }
        }

        public void Minimize()
        {
            CurWindowState = WindowState.Minimized;
        }

        public void Normalize()
        {
            CurWindowState = WindowState.Normal;
        }

        public void Maximize()
        {
            CurWindowState = WindowState.Maximized;
        }

        public static void BackPage()
        {
            PageNavigator.GoBack(1);
        }

        public void Close()
        {
            FrameContent = null;
        }

        public Action CloseAction { get; set; }
        public Action HideAction { get; set; }

        //AppExitCommand
        public static void AppExit() { Application.Current.MainWindow.Close(); Application.Current.Shutdown(); }

        public ICommand AppExitCommand { get { return new CommandHandler(() => AppExit(), _canExecute); } }
        public ICommand MinCommand { get { return new CommandHandler(() => Minimize(), _canExecute); } }
        public ICommand NormalCommand { get { return new CommandHandler(() => Normalize(), _canExecute); } }
        public ICommand MaxCommand { get { return new CommandHandler(() => Maximize(), _canExecute); } }

        public ICommand BackWinCommand { get { return new CommandHandler(() => BackWinPage(), _canExecute); } }
        public ICommand BackCommand { get { return new CommandHandler(() => BackWinPage(), _canExecute); } }
        public ICommand CloseCommand { get { return new CommandHandler(() => Close(), _canExecute); } }
    }
}



using Eli_CommandHandler_4_6;
using RevizeREVEXplus.Classes;
using RevizeREVEXplus.Models;
using System.ComponentModel;
using System.Windows;
using System.Windows.Input;

namespace RevizeREVEXplus.ViewModels
{
    public class MainWindowViewModel : CommandViewModel
    {
        private UserSettingService _userService;
        public MainWindowViewModel(UserSettingService userService)
        {
            _userService = userService;
        }

        public void LoadWindow()
        {
            CurWindowState = WindowState.Maximized;
        }

        public void WindowClosing(object sender, CancelEventArgs e)        {

            //if (WPFMessageBox.Show(Settings.Default.AppCloseDialog, Settings.Default.Warning, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            //{
            //    Save();
            //    string fileName = "Data.sdf";
            //    string sourcePath = ZakladniFce.GetDataDirectory();
            //    string copyPath = ZakladniFce.GetBackupsDirectory();

            //    string sourceFile = Path.Combine(sourcePath, fileName);
            //    string copyFile = Path.Combine(copyPath, fileName);

            //    if (Directory.Exists(copyFile))
            //    {
            //        Directory.Delete(copyFile);
            //        File.Copy(sourceFile, copyFile, true);
            //    }

            //    e.Cancel = false;
            //}
            //else
            //    e.Cancel = true;
        }

        private object _selectedCustomer;
        public object SelectCustomer
        {
            get
            {
                return _selectedCustomer;
            }
            set
            {
                _selectedCustomer = value;

                object val = _selectedCustomer;
                SelectedZakaznik = val as Zakaznik;
                SelectedSpotrebic = val as Spotrebic;
                SelectedUmisteni = val as Umisteni;
                SelectedMereni = val as Mereni;

                if (value is Zakaznik)
                {
                    var b = value as Zakaznik;
                    SelectedZakaznik.Id = b.Id;
                    _userService.CustomerId = b.Id;


                    Zakaznik();
                }

                if (value is Umisteni)
                {
                    var c = value as Umisteni;
                    SelectedUmisteni.Id = c.Id;
                    //_userService.PlaceId = c.Id;
                    //if (c.ParentPlaceId == null)
                    //    PlaceType = "Objekt";
                    //else
                    //    PlaceType = "Umístění";
                    //Location();

                }

                if (value is Spotrebic)
                {
                    var c = value as Spotrebic;
                    SelectedSpotrebic.Id = c.Id;
                    //_userService.RevisionId = c.Id;
                    //Appliance();
                }

                if (value is Mereni)
                {
                    var c = value as Mereni;
                    SelectedMereni.Id = c.Id;
                    //_userService.RevisionId = c.Id;
                    //Measure();
                }
            }
        }

        //public ICommand NewMeasureCommand { get { return new CommandHandler(() => NewMeasure(), _canExecute); } }
        public ICommand WindowLoadCommand { get { return new CommandHandler(() => LoadWindow(), _canExecute); } }
    }
}



using AresWebService;
using AresWebService.Ares;
using Eli_CommandHandler_4_6;
using RevizeREVEXplus.Classes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Input;

namespace RevizeREVEXplus.ViewModels
{
    public class ZakaznikViewModel : CommandViewModel
    {
        private UserSettingService _userService;

        public ZakaznikViewModel(UserSettingService userService)
        {
            _userService = userService;
        }

        public void Load()
        {
            if (_userService.CustomerId > 0)
                SelectedZakaznik = Zakaznici.Where(o => o.Id == _userService.CustomerId).FirstOrDefault();
        }

        public async void OverIco()
        {
            try
            {
                if (SelectedZakaznik != null)
                {
                    var icos = new string[] { SelectedZakaznik.Ic };
                    var requests = new List<AresRequest>();
                    foreach (var ico in icos)
                        requests.Add(new AresRequest() { FindIco = ico });

                    var a = new AresService();

                    var rarr = requests.ToArray();

                    if (rarr != null)
                    {
                        await a.FindAsync(rarr);

                        foreach (var req in rarr)
                        {
                            var si = req.Succesfull ? req.Response : new SubjectInfo();
                            SelectedZakaznik.Firma = si.CompanyName;
                            SelectedZakaznik.Ulice = si.Address.Street;
                            SelectedZakaznik.Cpop = si.Address.HomeNr1.ToString();
                            SelectedZakaznik.Obec = si.Address.City;
                            SelectedZakaznik.CastObce = si.Address.CityPart;
                            SelectedZakaznik.Psc = si.Address.ZIP;

                            if (si.LegalForm.Name.ToUpper().Contains("FYZICKÁ"))
                                SelectedZakaznik.FyzickaOs = true;
                            else
                                SelectedZakaznik.FyzickaOs = false;

                            if (si.Address.HomeNr2 != null)
                                SelectedZakaznik.Cor = si.Address.HomeNr2.ToString();
                            else
                                SelectedZakaznik.Cor = "";

                            if (!String.IsNullOrEmpty(si.Dic))
                                SelectedZakaznik.Dic = si.Dic;
                            else
                                SelectedZakaznik.Dic = "";

                            Save();

                            NotifyPropertyChanged(nameof(SelectedZakaznik));
                            NotifyPropertyChanged(nameof(Zakaznici));
                        }
                    }
                    else
                        MessageBox.Show("IČ nebylo v rejstříku ARES nalezeno!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        public ICommand PageLoadCommand { get { return new CommandHandler(() => Load(), _canExecute); } }
        public ICommand OverIcoCommand { get { return new CommandHandler(() => OverIco(), _canExecute); } }
    }
}


<Window x:Class="RevizeREVEXplus.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:enum="clr-namespace:RevizeREVEXplus.Enums"
        xmlns:mod="clr-namespace:RevizeREVEXplus.Models"
        xmlns:wi="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
        xmlns:behaviours="clr-namespace:RevizeREVEXplus.Classes"
        xmlns:System="clr-namespace:System;assembly=mscorlib"
        xmlns:local="clr-namespace:RevizeREVEXplus"
        mc:Ignorable="d"
        Title="" Height="850" Width="1200" DataContext="{Binding MainWindowViewModel, Source={StaticResource Locator}}" WindowState="Maximized" WindowStartupLocation="CenterScreen" Background="#FF3E3C3C" Name="MainWin">

    <Window.Resources>
        <ObjectDataProvider x:Key="EnStatus" MethodName="GetValues" ObjectType="{x:Type System:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="enum:EnStatus"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
        <ObjectDataProvider x:Key="EnVeliciny" MethodName="GetValues" ObjectType="{x:Type System:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="enum:EnJednotky"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    </Window.Resources>

    <wi:Interaction.Triggers>
        <wi:EventTrigger EventName="Loaded">
            <wi:InvokeCommandAction Command="{Binding WindowLoadCommand}"/>
        </wi:EventTrigger>
        <wi:EventTrigger EventName="Closing">
            <ei:CallMethodAction TargetObject="{Binding}" MethodName="WindowClosing"/>
        </wi:EventTrigger>
    </wi:Interaction.Triggers>

    <DockPanel LastChildFill="True" Name="MainDock">

        <Menu DockPanel.Dock="Top" Background="#FF3E3C3C">
            <MenuItem Header="Soubor" FontWeight="Black" Foreground="AntiqueWhite">

            </MenuItem>
            <MenuItem Header="Úprava" FontWeight="Black" Foreground="AntiqueWhite">

            </MenuItem>
            <MenuItem Header="Zobrazení" FontWeight="Black" Foreground="AntiqueWhite">

            </MenuItem>
            <MenuItem Header="Log" FontWeight="Black" Foreground="AntiqueWhite">

            </MenuItem>
            <MenuItem Header="O aplikaci" FontWeight="Black" Foreground="AntiqueWhite">

            </MenuItem>
        </Menu>

        <ToolBarTray DockPanel.Dock="Top" Background="#FF3E3C3C">
            <ToolBar Background="#FF3E3C3C">
                <Button Content="Revize" Style="{StaticResource ButtonStyle3}" Width="80" Command=""/>
                <Button Content="Šablony" Style="{StaticResource ButtonStyle3}" Width="80" Command=""/>
                <ComboBox ItemsSource="{Binding Source={StaticResource EnStatus}}" Width="150"  Style="{StaticResource Combo}"/>
                <ComboBox ItemsSource="{Binding Source={StaticResource EnVeliciny}}" Width="150"  Style="{StaticResource Combo}"/>

            </ToolBar>
        </ToolBarTray>
        <ToolBarTray DockPanel.Dock="Left" Background="#FF3E3C3C">
            <ToolBar Background="#FF3E3C3C">

            </ToolBar>
        </ToolBarTray>

        <StatusBar DockPanel.Dock="Bottom" Background="#FF3E3C3C" Height="32">
            <StatusBarItem Background="#FF3E3C3C">

            </StatusBarItem>
        </StatusBar>

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="200" MaxWidth="400" MinWidth="200"/>
                <ColumnDefinition Width="5"/>
                <ColumnDefinition Width="*" MinWidth="800"/>
            </Grid.ColumnDefinitions>

            <TreeView Name="trvCust" ItemsSource="{Binding Zakaznici, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Style="{StaticResource Tree}" Grid.ColumnSpan="2" Margin="10,0,0,0">
                <wi:Interaction.Behaviors>
                    <behaviours:BindableSelectedItemBehavior SelectedItem="{Binding SelectCustomer, Mode=TwoWay}"/>
                </wi:Interaction.Behaviors>

                <TreeView.ItemContainerStyle>
                    <Style TargetType="TreeViewItem">
                        <Setter Property="IsSelected" Value="{Binding IsSelected}" />
                        <Setter Property="IsExpanded" Value="{Binding IsExpanded}" />
                    </Style>
                </TreeView.ItemContainerStyle>

                <TreeView.Resources>
                    <HierarchicalDataTemplate DataType="{x:Type mod:Zakaznik}" ItemsSource="{Binding Umisteni}">
                        <StackPanel Orientation="Horizontal">
                            <StackPanel.ContextMenu>
                                <ContextMenu>
                                    <MenuItem Header="Zákazníka" Command="">
                                        <MenuItem.Icon>
                                            <Image  Source="/RevizeREVEXplus;component/Images/Add11.png" Width="15" Height="15"/>
                                        </MenuItem.Icon>
                                    </MenuItem>
                                    <MenuItem Header="Objekt" Command="">
                                        <MenuItem.Icon>
                                            <Image  Source="/RevizeREVEXplus;component/Images/Add11.png" Width="15" Height="15"/>
                                        </MenuItem.Icon>
                                    </MenuItem>
                                    <MenuItem Header="Zákazníka" Command="">
                                        <MenuItem.Icon>
                                            <Image  Width="15" Height="15" Source="/RevizeREVEXplus;component/Images/Add11.png"/>
                                        </MenuItem.Icon>
                                    </MenuItem>
                                    <MenuItem Header="Nastavení" Command="">

                                    </MenuItem>
                                </ContextMenu>
                            </StackPanel.ContextMenu>
                            <StackPanel Orientation="Vertical" Height="auto">
                                <Label Content="{Binding Firma}" FontWeight="Black" Style="{StaticResource  Label2}"/>
                            </StackPanel>
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type mod:Umisteni}" ItemsSource="{Binding Childrens}">
                        <StackPanel Orientation="Horizontal">
                            <StackPanel.ContextMenu>
                                <ContextMenu >
                                    <MenuItem Header="Umístění" Command="">
                                        <MenuItem.Icon>
                                            <Image  Source="/RevizeREVEXplus;component/Images/Add11.png" Width="15" Height="15"/>
                                        </MenuItem.Icon>
                                    </MenuItem>
                                    <MenuItem Header="Měření" Command="">
                                        <MenuItem.Icon>
                                            <Image  Source="/RevizeREVEXplus;component/Images/Add11.png" Width="15" Height="15"/>
                                        </MenuItem.Icon>
                                    </MenuItem>
                                    <MenuItem Header="Umístění" Command="">
                                        <MenuItem.Icon>
                                            <Image  Source="/RevizeREVEXplus;component/Images/Add11.png" Width="15" Height="15"/>
                                        </MenuItem.Icon>
                                    </MenuItem>
                                    <MenuItem Header="Nastavení" Command="">
                                        <MenuItem.Icon>
                                            <Image  Source="/RevizeREVEXplus;component/Images/Add11.png" Width="15" Height="15"/>
                                        </MenuItem.Icon>
                                    </MenuItem>
                                </ContextMenu>
                            </StackPanel.ContextMenu>
                            <Label Content="{Binding Místo}"  Style="{StaticResource  Label2}"/>
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type mod:Spotrebic}" ItemsSource="{Binding Mereni}">
                        <StackPanel Orientation="Horizontal">
                            <StackPanel.ContextMenu>
                                <ContextMenu >
                                    <MenuItem Header="Měření">
                                        <MenuItem.Icon>
                                            <Image  Source="/RevizeREVEXplus;component/Images/Add11.png" Width="15" Height="15"/>
                                        </MenuItem.Icon>
                                    </MenuItem>
                                    <MenuItem Header="Nastavení" Command="">
                                        <MenuItem.Icon>
                                            <Image  Source="/RevizeREVEXplus;component/Images/Add11.png" Width="15" Height="15"/>
                                        </MenuItem.Icon>
                                    </MenuItem>
                                </ContextMenu>
                            </StackPanel.ContextMenu>
                            <StackPanel Orientation="Vertical">
                                <Label Content="{Binding Nazev}" Style="{StaticResource  Label2}"/>
                            </StackPanel>
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type mod:Mereni}">
                        <StackPanel Orientation="Horizontal">
                            <StackPanel.ContextMenu>
                                <ContextMenu >
                                    <MenuItem Header="Revizi">
                                        <MenuItem.Icon>
                                            <Image  Source="/RevizeREVEXplus;component/Images/Add11.png" Width="15" Height="15"/>
                                        </MenuItem.Icon>
                                    </MenuItem>
                                    <MenuItem Header="Nastavení" Command="">
                                        <MenuItem.Icon>
                                            <Image Source="/RevizeREVEXplus;component/Images/Doc11.png" Width="15" Height="15"/>
                                        </MenuItem.Icon>
                                    </MenuItem>
                                </ContextMenu>
                            </StackPanel.ContextMenu>
                            <StackPanel Orientation="Vertical">
                                <Label Content="{Binding MeasDate}" Style="{StaticResource Label2}"/>
                            </StackPanel>
                        </StackPanel>
                    </HierarchicalDataTemplate>
                </TreeView.Resources>
            </TreeView>
            <GridSplitter Grid.Column="1" Width="5" Background="Silver" HorizontalAlignment="Stretch"/>

            <Frame x:Name="frame" Content="{Binding FrameContent}" Grid.Column="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" NavigationUIVisibility="Hidden"/>

        </Grid>
    </DockPanel>
</Window>



<Page x:Class="RevizeREVEXplus.Views.ZakaznikView"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:wi="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
      xmlns:local="clr-namespace:RevizeREVEXplus.Views"
      mc:Ignorable="d"
      d:DesignHeight="450" d:DesignWidth="800" DataContext="{Binding ZakaznikViewModel, Source={StaticResource Locator}}" Name="ZakView"
      Title="ZakaznikView">

    <wi:Interaction.Triggers>
        <wi:EventTrigger EventName="Loaded">
            <wi:InvokeCommandAction Command="{Binding PageLoadCommand}"/>
        </wi:EventTrigger>
    </wi:Interaction.Triggers>

    <TabControl x:Name="Tab" Background="#FF3E3C3C" >

        <!--#region TabItem Detail zákazníka-->
        <TabItem Header="Detail zákazníka / nový zákazník">
            <Grid Background="#FF3E3C3C">
                <Grid.RowDefinitions>
                    <RowDefinition Height="400" MinHeight="350"/>
                    <RowDefinition Height="10"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <GroupBox Header="Zákazník">

                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>

                        <!--#region Grid Adresa-->
                        <Grid Grid.Column="0">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="auto"/>
                                <ColumnDefinition Width="55"/>
                                <ColumnDefinition Width="25"/>
                                <ColumnDefinition Width="15"/>
                                <ColumnDefinition Width="30"/>
                                <ColumnDefinition Width="75"/>
                                <ColumnDefinition Width="120"/>
                                <ColumnDefinition Width="35"/>
                                <ColumnDefinition Width="35"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="35"/>
                                <RowDefinition Height="35"/>
                                <RowDefinition Height="70" MaxHeight="70"/>
                                <RowDefinition Height="35"/>
                                <RowDefinition Height="35"/>
                                <RowDefinition Height="35"/>
                                <RowDefinition Height="35"/>
                                <RowDefinition Height="35"/>
                                <RowDefinition Height="35"/>
                                <RowDefinition Height="35"/>
                                <RowDefinition Height="35"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>

                            <Label Content="Fyzická os.:" Grid.Column="0" Grid.Row="0" FontWeight="ExtraBlack" Style="{StaticResource Label2}"/>
                            <Label Content="IČ (ID):" Grid.Column="0" Grid.Row="1" FontWeight="ExtraBlack" Style="{StaticResource Label2}"/>
                            <Label Content="Zákazník:" Grid.Column="0" Grid.Row="2" Style="{StaticResource Label2}" VerticalAlignment="Top"/>

                            <Label Content="Ulice:" Grid.Column="0" Grid.Row="4" Style="{StaticResource Label2}"/>
                            <Label Content="Ulice:" Grid.Column="0" Grid.Row="4" Style="{StaticResource Label2}"/>
                            <Label Content="Č. pop.:" Grid.Column="0" Grid.Row="5" Style="{StaticResource Label2}"/>
                            <Label Content="Č. or.:" Grid.Column="3" Grid.ColumnSpan="2" Grid.Row="5" Style="{StaticResource Label2}"/>
                            <Label Content="PSČ/Obec:" Grid.Column="0" Grid.Row="6" Style="{StaticResource Label2}"/>
                            <Label Content="DIČ:" Grid.Column="0" Grid.Row="7" Style="{StaticResource Label2}"/>

                            <CheckBox IsChecked="{Binding SelectedZakaznik.FyzickaOs}" Grid.Column="1" Grid.Row="0"/>

                            <TextBox Text="{Binding Path=SelectedZakaznik.Ic}"  Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2" MaxLength="8"/>
                            <Button Content="Vyplnit z Ares" Command="{Binding Path=OverIcoCommand}" Grid.Column="3" Grid.ColumnSpan="3" Grid.Row="1" FontWeight="ExtraBlack" FontSize="14" Style="{StaticResource ButtonStyle3}" Foreground="Yellow" Width="120" Height="30"/>

                            <TextBox Text="{Binding Path=SelectedZakaznik.Firma}"  Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="6" Grid.RowSpan="2" TextWrapping="Wrap" AcceptsReturn="True"/>

                            <TextBox Text="{Binding SelectedZakaznik.Ulice}"  Grid.Column="1" Grid.Row="4" Grid.ColumnSpan="6"/>
                            <TextBox Text="{Binding SelectedZakaznik.Cpop}"  Grid.Column="1" Grid.Row="5" Grid.ColumnSpan="2"/>
                            <TextBox Text="{Binding SelectedZakaznik.Cor}"  Grid.Column="5" Grid.Row="5"/>

                            <TextBox Text="{Binding SelectedZakaznik.Psc}" Grid.Column="1" Grid.Row="6" Grid.ColumnSpan="1"/>
                            <TextBox Text="{Binding SelectedZakaznik.Obec}" Grid.Column="3" Grid.Row="6" Grid.ColumnSpan="4"/>

                            <TextBox Text="{Binding SelectedZakaznik.Dic}"  Grid.Column="1" Grid.Row="7" Grid.ColumnSpan="3" MaxLength="12"/>
                        </Grid>
                        <!--#endregion-->

                        <!--#region Grid Kontakty-->
                        <Grid Grid.Column="1">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="auto"/>
                                <ColumnDefinition Width="300"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="35"/>
                                <RowDefinition Height="35"/>
                                <RowDefinition Height="35"/>
                                <RowDefinition Height="35"/>
                                <RowDefinition Height="35"/>
                                <RowDefinition Height="35"/>
                                <RowDefinition Height="35"/>
                                <RowDefinition Height="35"/>
                                <RowDefinition Height="35"/>
                                <RowDefinition Height="35"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>

                            <Grid Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="5" Width="auto" HorizontalAlignment="Stretch">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Button Content="Nový" Command="" Grid.Column="0" HorizontalAlignment="Stretch" Style="{StaticResource ButtonStyle3}"/>
                                <Button Content="Uložit" Command="{Binding Path=SaveCommand}" Grid.Column="1" HorizontalAlignment="Stretch" Style="{StaticResource ButtonStyle3}"/>
                                <Button Content="Vymazat" Command="" Grid.Column="2" HorizontalAlignment="Stretch" Style="{StaticResource ButtonStyle3}"/>
                            </Grid>

                            <Label Content="Telefon:" Grid.Column="0" Grid.Row="2" Style="{StaticResource Label2}"/>
                            <Label Content="Gsm:" Grid.Column="0" Grid.Row="3" Style="{StaticResource Label2}"/>
                            <Label Content="E-mail:" Grid.Column="0" Grid.Row="4" Style="{StaticResource Label2}"/>
                            <Label Content="Web:" Grid.Column="0" Grid.Row="5" Style="{StaticResource Label2}"/>

                            <TextBox Text="{Binding SelectedZakaznik.Telefon}" Grid.Column="1" Grid.Row="2"/>
                            <TextBox Text="{Binding SelectedZakaznik.Mobil}" Grid.Column="1" Grid.Row="3"/>
                            <TextBox Text="{Binding SelectedZakaznik.Email}" Grid.Column="1" Grid.Row="4"/>
                            <TextBox Text="{Binding SelectedZakaznik.Web}" Grid.Column="1" Grid.Row="5"/>
                        </Grid>
                        <!--#endregion-->
                    </Grid>
                </GroupBox>

                <GridSplitter Height="10" Background="Aqua" BorderThickness="4" BorderBrush="#FF592323" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Grid.Row="1"/>

                <!--#region TabControl zákazník doplňky-->
                <TabControl Background="Transparent" Grid.Row="2">
                    <TabItem Header="Poznámka">
                        <TextBox Text="{Binding SelectedZakaznik.Poznamka}" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Visible"/>
                    </TabItem>
                    <TabItem Header="Adresy">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>

                            <GroupBox Header="Fakturační adresa" Grid.Row="0" Grid.ColumnSpan="5">
                                <UniformGrid Columns="6" Rows="2" HorizontalAlignment="Stretch">
                                    <Label Content="Ulice" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                    <Label Content="Číslo popisné" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                    <Label Content="Číslo orientační" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                    <Label Content="Obec" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                    <Label Content="Část obce" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                    <Label Content="PSČ" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                    <TextBlock Text="{Binding SelectedZakaznik.Ulice}" HorizontalAlignment="Center"/>
                                    <TextBlock Text="{Binding SelectedZakaznik.Cpop}" HorizontalAlignment="Center"/>
                                    <TextBlock Text="{Binding SelectedZakaznik.Cor}" HorizontalAlignment="Center"/>
                                    <TextBlock Text="{Binding SelectedZakaznik.Obec}" HorizontalAlignment="Center"/>
                                    <TextBlock Text="{Binding SelectedZakaznik.CastObce}" HorizontalAlignment="Center"/>
                                    <TextBlock Text="{Binding SelectedZakaznik.Psc}" Grid.Row="0" HorizontalAlignment="Center"/>
                                </UniformGrid>
                            </GroupBox>
                            <GroupBox Header="Ostatní adresy" Grid.Row="1" Grid.ColumnSpan="5">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="auto"/>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>

                                    <Grid Grid.Row="0">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="*"/>
                                            <RowDefinition Height="*"/>
                                            <RowDefinition Height="*"/>
                                        </Grid.RowDefinitions>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="*"/>

                                        </Grid.ColumnDefinitions>

                                        <UniformGrid Columns="8" Rows="2" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Stretch">
                                            <Label Content="Druh adresy" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                            <Label Content="Ulice" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                            <Label Content="Číslo popisné" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                            <Label Content="Číslo orientační" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                            <Label Content="Obec" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                            <Label Content="Část obce" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                            <Label Content="PSČ" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                            <Label Content="Poznámka" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                            <TextBox Text="{Binding SelectedJinaAdresa.Druh}" HorizontalAlignment="Center"/>
                                            <TextBox Text="{Binding SelectedJinaAdresa.Ulice}" HorizontalAlignment="Center"/>
                                            <TextBox Text="{Binding SelectedJinaAdresa.Cpop}" HorizontalAlignment="Center"/>
                                            <TextBox Text="{Binding SelectedJinaAdresa.Cor}" HorizontalAlignment="Center"/>
                                            <TextBox Text="{Binding SelectedJinaAdresa.Obec}" HorizontalAlignment="Center"/>
                                            <TextBox Text="{Binding SelectedJinaAdresa.CastObce}" Grid.Row="0" HorizontalAlignment="Center"/>
                                            <TextBox Text="{Binding SelectedJinaAdresa.Psc}" Grid.Row="0" HorizontalAlignment="Center"/>
                                            <TextBox Text="{Binding SelectedJinaAdresa.Poznamka}" Grid.Row="0" HorizontalAlignment="Center"/>
                                        </UniformGrid>

                                        <UniformGrid Columns="3" Rows="1" Grid.Row="1" Grid.Column="2">
                                            <Button Content="Nová adresa" Command="" Grid.Column="0" HorizontalAlignment="Stretch" Style="{StaticResource ButtonStyle3}"/>
                                            <Button Content="Ulož změny" Command="" Grid.Column="1" HorizontalAlignment="Stretch" Style="{StaticResource ButtonStyle3}"/>
                                            <Button Content="Vymaž adresu" Command="" Grid.Column="2" HorizontalAlignment="Stretch" Style="{StaticResource ButtonStyle3}"/>
                                        </UniformGrid>
                                    </Grid>

                                    <DataGrid Grid.Row="1" SelectedItem="{Binding SelectedJinaAdresa}" HorizontalAlignment="Stretch" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                                        <DataGrid.Columns>
                                            <DataGridTextColumn Binding="{Binding Druh}" Header="Druh adresy"/>
                                            <DataGridTextColumn Binding="{Binding Ulice}" Header="Ulice" Width="*"/>
                                            <DataGridTextColumn Binding="{Binding Cpop}" Header="Číslo popisné"/>
                                            <DataGridTextColumn Binding="{Binding Cor}" Header="Číslo orientační"/>
                                            <DataGridTextColumn Binding="{Binding Obec}" Header="Obec" Width="*"/>
                                            <DataGridTextColumn Binding="{Binding CastObce}" Header="Část obce" Width="*"/>
                                            <DataGridTextColumn Binding="{Binding Psc}" Header="PSČ"/>
                                            <DataGridTextColumn Binding="{Binding Poznamka}" Header="Poznámka" Width="*"/>
                                        </DataGrid.Columns>
                                    </DataGrid>
                                </Grid>

                            </GroupBox>
                        </Grid>
                    </TabItem>
                    <TabItem Header="Kontakty">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>

                            <GroupBox Header="Kontakntí osoby" Grid.ColumnSpan="5">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="auto"/>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>

                                    <Grid Grid.Row="0">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="*"/>
                                            <RowDefinition Height="*"/>
                                            <RowDefinition Height="*"/>
                                        </Grid.RowDefinitions>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="*"/>
                                        </Grid.ColumnDefinitions>

                                        <UniformGrid Columns="1" Rows="1" Grid.Row="1" Grid.Column="3">
                                            <Button Content="Detail kontaktu" Command="" Grid.Column="2" HorizontalAlignment="Stretch" Style="{StaticResource ButtonStyle3}"/>
                                        </UniformGrid>
                                    </Grid>

                                    <DataGrid Grid.Row="1" ItemsSource="{Binding ElementName=Tab}" SelectedItem="{Binding SelectedOsoba}" HorizontalAlignment="Stretch" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                                        <!--<wi:Interaction.Triggers>
                                            <wi:EventTrigger EventName="MouseDoubleClick">
                                                <wi:InvokeCommandAction Command="{Binding UpravOsobuCommand}"/>
                                            </wi:EventTrigger>
                                        </wi:Interaction.Triggers>-->
                                        <DataGrid.Columns>
                                            <DataGridTextColumn Binding="{Binding Funkce}" Header="Funkce"/>
                                            <DataGridTextColumn Binding="{Binding TitulPred}" Header="Titul"/>
                                            <DataGridTemplateColumn Header="Jméno /druhé jméno/ příjmení" Width="*">
                                                <DataGridTemplateColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <StackPanel Orientation="Horizontal">
                                                            <TextBlock Text="{Binding Jmeno}"/>
                                                            <TextBlock Text=" /"/>
                                                            <TextBlock Text="{Binding DruheJmeno}"/>
                                                            <TextBlock Text="/ "/>
                                                            <TextBlock Text="{Binding Prijmeni}"/>
                                                        </StackPanel>
                                                    </DataTemplate>
                                                </DataGridTemplateColumn.CellTemplate>
                                            </DataGridTemplateColumn>
                                            <DataGridTextColumn Binding="{Binding TitulZa}" Header="Titul"/>
                                            <DataGridTextColumn Binding="{Binding Poznamka}" Header="Poznámka" Width="*"/>
                                        </DataGrid.Columns>
                                    </DataGrid>
                                </Grid>

                            </GroupBox>
                        </Grid>
                    </TabItem>
                    <TabItem Header="Bankovní účty">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>

                            <GroupBox Header="Fakturační adresa" Grid.Row="0" Grid.ColumnSpan="5">
                                <UniformGrid Columns="6" Rows="2" HorizontalAlignment="Stretch">
                                    <Label Content="Ulice" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                    <Label Content="Číslo popisné" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                    <Label Content="Číslo orientační" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                    <Label Content="Obec" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                    <Label Content="Část obce" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                    <Label Content="PSČ" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                    <TextBlock Text="{Binding SelectedZakaznik.Ulice}" HorizontalAlignment="Center"/>
                                    <TextBlock Text="{Binding SelectedZakaznik.Cpop}" HorizontalAlignment="Center"/>
                                    <TextBlock Text="{Binding SelectedZakaznik.Cor}" HorizontalAlignment="Center"/>
                                    <TextBlock Text="{Binding SelectedZakaznik.Obec}" HorizontalAlignment="Center"/>
                                    <TextBlock Text="{Binding SelectedZakaznik.CastObce}" HorizontalAlignment="Center"/>
                                    <TextBlock Text="{Binding SelectedZakaznik.Psc}" Grid.Row="0" HorizontalAlignment="Center"/>
                                </UniformGrid>
                            </GroupBox>
                            <GroupBox Header="Ostatní adresy" Grid.Row="1" Grid.ColumnSpan="5">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="auto"/>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>

                                    <Grid Grid.Row="0">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="*"/>
                                            <RowDefinition Height="*"/>
                                            <RowDefinition Height="*"/>
                                        </Grid.RowDefinitions>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="*"/>

                                        </Grid.ColumnDefinitions>

                                        <UniformGrid Columns="8" Rows="2" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Stretch">
                                            <Label Content="Druh adresy" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                            <Label Content="Ulice" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                            <Label Content="Číslo popisné" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                            <Label Content="Číslo orientační" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                            <Label Content="Obec" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                            <Label Content="Část obce" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                            <Label Content="PSČ" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                            <Label Content="Poznámka" FontStyle="Italic" HorizontalContentAlignment="Center" Style="{StaticResource Label1}"/>
                                            <TextBox Text="{Binding SelectedJinaAdresa.Druh}" HorizontalAlignment="Center"/>
                                            <TextBox Text="{Binding SelectedJinaAdresa.Ulice}" HorizontalAlignment="Center"/>
                                            <TextBox Text="{Binding SelectedJinaAdresa.Cpop}" HorizontalAlignment="Center"/>
                                            <TextBox Text="{Binding SelectedJinaAdresa.Cor}" HorizontalAlignment="Center"/>
                                            <TextBox Text="{Binding SelectedJinaAdresa.Obec}" HorizontalAlignment="Center"/>
                                            <TextBox Text="{Binding SelectedJinaAdresa.CastObce}" Grid.Row="0" HorizontalAlignment="Center"/>
                                            <TextBox Text="{Binding SelectedJinaAdresa.Psc}" Grid.Row="0" HorizontalAlignment="Center"/>
                                            <TextBox Text="{Binding SelectedJinaAdresa.Poznamka}" Grid.Row="0" HorizontalAlignment="Center"/>
                                        </UniformGrid>

                                        <UniformGrid Columns="3" Rows="1" Grid.Row="1" Grid.Column="2">
                                            <Button Content="Nová adresa" Command="" Grid.Column="0" HorizontalAlignment="Stretch" Style="{StaticResource ButtonStyle3}"/>
                                            <Button Content="Ulož změny" Command="" Grid.Column="1" HorizontalAlignment="Stretch" Style="{StaticResource ButtonStyle3}"/>
                                            <Button Content="Vymaž adresu" Command="" Grid.Column="2" HorizontalAlignment="Stretch" Style="{StaticResource ButtonStyle3}"/>
                                        </UniformGrid>
                                    </Grid>

                                    <DataGrid Grid.Row="1" SelectedItem="{Binding SelectedJinaAdresa}" HorizontalAlignment="Stretch" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                                        <DataGrid.Columns>
                                            <DataGridTextColumn Binding="{Binding Druh}" Header="Druh adresy"/>
                                            <DataGridTextColumn Binding="{Binding Ulice}" Header="Ulice" Width="*"/>
                                            <DataGridTextColumn Binding="{Binding Cpop}" Header="Číslo popisné"/>
                                            <DataGridTextColumn Binding="{Binding Cor}" Header="Číslo orientační"/>
                                            <DataGridTextColumn Binding="{Binding Obec}" Header="Obec" Width="*"/>
                                            <DataGridTextColumn Binding="{Binding CastObce}" Header="Část obce" Width="*"/>
                                            <DataGridTextColumn Binding="{Binding Psc}" Header="PSČ"/>
                                            <DataGridTextColumn Binding="{Binding Poznamka}" Header="Poznámka" Width="*"/>
                                        </DataGrid.Columns>
                                    </DataGrid>
                                </Grid>

                            </GroupBox>
                        </Grid>
                    </TabItem>
                    <TabItem Header="Fakturace">

                    </TabItem>
                    <TabItem Header="Přílohy">

                    </TabItem>
                </TabControl>
                <!--#endregion-->
            </Grid>
        </TabItem>
        <!--#endregion-->
        <!--#region TabItem Seznam zákazníků-->
        <!--<TabItem Header="Seznam zákazníků">
            <DataGrid ItemsSource="{Binding Zakaznici}" SelectedItem="{Binding SelectedZakaznik}" AutoGenerateColumns="False">
                <wi:Interaction.Triggers>
                    <wi:EventTrigger EventName="MouseDoubleClick">
                        <wi:InvokeCommandAction Command="{Binding DetailZakaznikCommand}"/>
                    </wi:EventTrigger>
                </wi:Interaction.Triggers>
                <DataGrid.Columns>
                    <DataGridTextColumn Header="IČ" Binding="{Binding Ic}"/>
                    <DataGridTextColumn Header="ID" Binding="{Binding ZakaznikId}"/>
                    <DataGridTextColumn Header="Firma" Binding="{Binding Firma}" Width="*"/>
                    <DataGridTextColumn Header="Ulice" Binding="{Binding Ulice}" Width="*"/>
                    <DataGridTextColumn Header="Č. pop." Binding="{Binding Cpop}"/>
                    <DataGridTextColumn Header="Č. or." Binding="{Binding Cor}"/>
                    <DataGridTextColumn Binding="{Binding Obec}" Header="Obec" Width="*"/>
                    <DataGridTextColumn Binding="{Binding CastObce}" Header="Část obce" Width="*"/>
                    <DataGridTextColumn Binding="{Binding Psc}" Header="PSČ"/>
                </DataGrid.Columns>
            </DataGrid>
        </TabItem>-->
        <!--#endregion-->
    </TabControl>
</Page>

Chci docílit: Tato aplikace má sloužit k evidenci revizí el. spotřebičů a ovládání měřícího přístroje. Komunikaci s přístrojem a další dílčí části už mám v podstatě vyřešené, teď se to snažím zkompletovat, ale narazil jsem. Vyzkoušel jsem už kde co, ale bez výsledku.
Kde dělám chybu?

 
Odpovědět
2.3.2021 9:19
Avatar
Maros2470
Člen
Avatar
Maros2470:2.3.2021 18:46

Tak se zdá, že jsem na to přišel. Chyba byla v BaseViewModel.
Měl jsem tam

readonly DataModel context = new DataModel();

namísto

static DataModel context = new DataModel();

I tak bych byl rád, kdyby někdo posoudil jestli postupuji při sestavování kódu správně.

Díky

 
Nahoru Odpovědět
2.3.2021 18:46
Děláme co je v našich silách, aby byly zdejší diskuze co nejkvalitnější. Proto do nich také mohou přispívat pouze registrovaní členové. Pro zapojení do diskuze se přihlas. Pokud ještě nemáš účet, zaregistruj se, je to zdarma.

Zobrazeno 2 zpráv z 2.