C#WPF应用程序在UserControl中保存设置

C#WPF应用程序在UserControl中保存设置,c#,wpf,user-controls,C#,Wpf,User Controls,我有一个主要的应用程序在这有不同的按钮。这还包括“Einstellung”按钮。按下此按钮应显示与以前不同的内容。这是我通过用户控件实现的 现在,您可以在此用户控件中进行设置并保存它们 这是我在设置中进行的保存 还有密码 Vorschau.Properties.Settings.Default.BreiteBitmap = Int32.Parse(tbBreiteBitmap.Text); Vorschau.Properties.Settings.Default.HoeheBitmap = I

我有一个主要的应用程序在这有不同的按钮。这还包括“Einstellung”按钮。按下此按钮应显示与以前不同的内容。这是我通过用户控件实现的

现在,您可以在此用户控件中进行设置并保存它们

这是我在设置中进行的保存

还有密码

Vorschau.Properties.Settings.Default.BreiteBitmap = Int32.Parse(tbBreiteBitmap.Text);
Vorschau.Properties.Settings.Default.HoeheBitmap = Int32.Parse(tbHoeheBitmap.Text);
Vorschau.Properties.Settings.Default.AnzahlKoordinaten = Int32.Parse(tbAnzahlKoordinaten.Text);
现在我按下“Speichen”按钮。他帮我保存设置。 现在我更改了UserControl,所以我点击一个按钮“Vorschau”,一个新的内容显示给我。如果我现在再次点击“Einstellung”,内容是否仍然存在,就像我存储的一样

但问题来了。我关闭应用程序,然后再次打开它。现在我点击文本框中的“Einstellung”按钮,它的任何地方都只有一个0

不应该是这样,但内容应该是过去的

我在启动应用程序时检索此内容。请参阅代码片段

 public UCEinstellung()
        {
            InitializeComponent();

            //Lade der Einstellungen
            tbBreiteBitmap.Text = Vorschau.Properties.Settings.Default.BreiteBitmap.ToString();
            tbHoeheBitmap.Text = Vorschau.Properties.Settings.Default.HoeheBitmap.ToString();
            tbAnzahlKoordinaten.Text = Vorschau.Properties.Settings.Default.AnzahlKoordinaten.ToString();
        }

不幸的是,这不起作用。 我希望你能告诉我错误在哪里。在另一个没有usercontrol的应用程序中,此存储和检索正确

UCEinstellung

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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;
using System.Diagnostics;

namespace Vorschau
{
    /// <summary>
    /// Interaktionslogik für UCEinstellung.xaml
    /// </summary>
    public partial class UCEinstellung : UserControl
    {
        public UCEinstellung()
        {
            InitializeComponent();

            //Lade der Einstellungen
            tbBreiteBitmap.Text = Vorschau.Properties.Settings.Default.BreiteBitmap.ToString();
            tbHoeheBitmap.Text = Vorschau.Properties.Settings.Default.HoeheBitmap.ToString();
            tbAnzahlKoordinaten.Text = Vorschau.Properties.Settings.Default.AnzahlKoordinaten.ToString();
        }

        private static Boolean kontrolliereObZahl(String pText)
        {
            int zahl1;
            double zahl2;
            Boolean istZahl;
            if (Int32.TryParse(pText, out zahl1) || Double.TryParse(pText, out zahl2))
            {
                istZahl = true;
            }
            else
            {
                istZahl = false;
            }
            return istZahl;
        }

        private static Boolean textfeldRot(String pBreiteBitmap, String pHoeheBitmap, String pAnzahlKoordinaten)
        {
            Boolean istRot = true;
            if (pBreiteBitmap.Equals("61381638") || pHoeheBitmap.Equals("61381638") || pAnzahlKoordinaten.Equals("61381638"))
            {
                istRot = true;
            }
            else
            {
                istRot = false;
            }
            return istRot;
        }
        private void btSpeichern_Click(object sender, RoutedEventArgs e)
        {

                if (textfeldRot(tbBreiteBitmap.BorderBrush.GetHashCode().ToString(), tbHoeheBitmap.BorderBrush.GetHashCode().ToString(), tbAnzahlKoordinaten.BorderBrush.GetHashCode().ToString()))
                {
                    MessageBox.Show("Leider beinhalten die Eingabefelder falsche Werte.\n\nVersuchen Sie es bitte erneut.", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    try
                    {
                        Vorschau.Properties.Settings.Default.BreiteBitmap = Int32.Parse(tbBreiteBitmap.Text);
                        Vorschau.Properties.Settings.Default.HoeheBitmap = Int32.Parse(tbHoeheBitmap.Text);
                        Vorschau.Properties.Settings.Default.AnzahlKoordinaten = Int32.Parse(tbAnzahlKoordinaten.Text);
                        MessageBox.Show("Einstellungen wurden erfolgreich abgespeichert.", "Speicherung erfolgreich", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                    }
                    catch (Exception error)
                    {

                        MessageBox.Show("Unglücklicherweise trat beim Speichervorgang ein Fehler auf.\n\nVersuchen Sie es bitte erneut.", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
                        Debug.WriteLine("Error - beim Speichervorgang " + error);
                    }
                }            
        }

        private void tbBreiteBitmap_LostFocus(object sender, RoutedEventArgs e)
        {
            try
            {
                if (kontrolliereObZahl(tbBreiteBitmap.Text) == false)
                {
                    tbBreiteBitmap.BorderBrush = Brushes.Red;
                }
                else
                {
                    tbBreiteBitmap.BorderBrush = Brushes.LightGray;
                }
            }
            catch (Exception error)
            {
                Debug.WriteLine("Error 'tbBreitBitMap'" + error);
            }
        }

        private void tbHoeheBitmap_LostFocus(object sender, RoutedEventArgs e)
        {
            try
            {
                if (kontrolliereObZahl(tbHoeheBitmap.Text) == false)
                {
                    tbHoeheBitmap.BorderBrush = Brushes.Red;
                }
                else
                {
                    tbHoeheBitmap.BorderBrush = Brushes.LightGray;
                }
            }
            catch (Exception error)
            {
                Debug.WriteLine("Error 'tbHoeheBitmap'" + error);
            }
        }

        private void tbAnzahlKoordinaten_LostFocus(object sender, RoutedEventArgs e)
        {
            try
            {
                if (kontrolliereObZahl(tbAnzahlKoordinaten.Text) == false)
                {
                    tbAnzahlKoordinaten.BorderBrush = Brushes.Red;
                }
                else
                {
                    tbAnzahlKoordinaten.BorderBrush = Brushes.LightGray;
                }
            }
            catch (Exception error)
            {
                Debug.WriteLine("Error 'tbAnzahlKoordinaten'" + error);
            }
        }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用System.Threading.Tasks;
使用System.Windows;
使用System.Windows.Controls;
使用System.Windows.Data;
使用System.Windows.Documents;
使用System.Windows.Input;
使用System.Windows.Media;
使用System.Windows.Media.Imaging;
使用System.Windows.Navigation;
使用System.Windows.Shapes;
使用系统诊断;
名称空间Vorschau
{
/// 
///für UCEinstellung.xaml的跨部门物流
/// 
公共部分类UCEinstellung:UserControl
{
公共教育
{
初始化组件();
//艾因斯特伦根酒店
tbBreiteBitmap.Text=Vorschau.Properties.Settings.Default.BreiteBitmap.ToString();
tbHoeheBitmap.Text=Vorschau.Properties.Settings.Default.HoeheBitmap.ToString();
tbAnzahlKoordinaten.Text=Vorschau.Properties.Settings.Default.AnzahlKoordinaten.ToString();
}
私有静态布尔值kontrollierobzahl(字符串pText)
{
int zahl1;
双zahl2;
布尔伊斯特扎尔;
if(Int32.TryParse(pText,out-zahl1)| Double.TryParse(pText,out-zahl2))
{
istZahl=真;
}
其他的
{
istZahl=假;
}
返回伊斯特扎尔;
}
私有静态布尔textfeldRot(字符串pBreiteBitmap、字符串PHOEEBITMAP、字符串PANZAHLKOORDIEN)
{
布尔值istRot=true;
如果(pBreiteBitmap.Equals(“61381638”)| PHOEHTMAP.Equals(“61381638”)| PANZAHLKOORDIEN.Equals(“61381638”))
{
istRot=真;
}
其他的
{
istRot=假;
}
返回istRot;
}
私有无效btSpeichern\u单击(对象发送者,路由目标e)
{
if(textfeldRot(tbbreite位图.BorderBrush.GetHashCode().ToString(),tbhoehbitmap.BorderBrush.GetHashCode().ToString(),tbanzahLkoordinaden.BorderBrush.GetHashCode().ToString())
{
MessageBox.Show(“Leider beinhalten die Eingabefeld falsche Werte.\n\n请将您的邮件重新发送给我。”,“Fehler”,MessageBoxButton.OK,MessageBoxImage.Error);
}
其他的
{
尝试
{
Vorschau.Properties.Settings.Default.BreiteBitmap=Int32.Parse(tbBreiteBitmap.Text);
Vorschau.Properties.Settings.Default.HoeheBitmap=Int32.Parse(tbHoeheBitmap.Text);
Vorschau.Properties.Settings.Default.AnzahlKoordinaten=Int32.Parse(tbAnzahlKoordinaten.Text);
MessageBox.Show(“Einstellungen-wurden-erfolgreich-abgespeichert.”,“speichreung-erfolgreich”,MessageBoxButton.OK,MessageBoxImage.Asterisk);
}
捕获(异常错误)
{
MessageBox.Show(“Unglücklicherweise trat beim Speichervorgang ein Fehler auf.\n\n请将您的信息发送给用户。”,“Fehler”,MessageBoxButton.OK,MessageBoxImage.Error);
Debug.WriteLine(“错误-beim Speichervorgang”+错误);
}
}            
}
私有void tbBreiteBitmap_LostFocus(对象发送方,路由目标)
{
尝试
{
if(kontrollieroobzahl(tbBreiteBitmap.Text)==false)
{
tbBreiteBitmap.BorderBrush=画笔.Red;
}
其他的
{
tbBreiteBitmap.BorderBrush=笔刷.LightGray;
}
}
捕获(异常错误)
{
Debug.WriteLine(“错误'tbBreitBitMap'”+错误);
}
}
私有void tbhoehebmap\u LostFocus(对象发送方,路由目标)
{
尝试
{
if(kontrollieroobzahl(tbHoeheBitmap.Text)==false)
{
tbHoeheBitmap.BorderBrush=画笔.Red;
}
其他的
{
tbhoehebtmap.BorderBrush=笔刷.LightGray;
}
}
捕获(异常错误)
{
Debug.WriteLine(“错误'tbhoehebimat'”+错误);
}
}
私有void tbanzahlkordinardien_LostFocus(对象发送方、路由目标方)
{
尝试
{
if(kontrollierobzahl(tbAnzahlKoordinaten.Text)==false)
{
tbanzahlkoordinaren.BorderBrush=刷子
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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;
using System.Diagnostics;

namespace Vorschau
{
    /// <summary>
    /// Interaktionslogik für UCEinstellung.xaml
    /// </summary>
    public partial class UCEinstellung : UserControl
    {
        public UCEinstellung()
        {
            InitializeComponent();

            //Lade der Einstellungen
            tbBreiteBitmap.Text = Vorschau.Properties.Settings.Default.BreiteBitmap.ToString();
            tbHoeheBitmap.Text = Vorschau.Properties.Settings.Default.HoeheBitmap.ToString();
            tbAnzahlKoordinaten.Text = Vorschau.Properties.Settings.Default.AnzahlKoordinaten.ToString();
        }

        private static Boolean kontrolliereObZahl(String pText)
        {
            int zahl1;
            double zahl2;
            Boolean istZahl;
            if (Int32.TryParse(pText, out zahl1) || Double.TryParse(pText, out zahl2))
            {
                istZahl = true;
            }
            else
            {
                istZahl = false;
            }
            return istZahl;
        }

        private static Boolean textfeldRot(String pBreiteBitmap, String pHoeheBitmap, String pAnzahlKoordinaten)
        {
            Boolean istRot = true;
            if (pBreiteBitmap.Equals("61381638") || pHoeheBitmap.Equals("61381638") || pAnzahlKoordinaten.Equals("61381638"))
            {
                istRot = true;
            }
            else
            {
                istRot = false;
            }
            return istRot;
        }
        private void btSpeichern_Click(object sender, RoutedEventArgs e)
        {

                if (textfeldRot(tbBreiteBitmap.BorderBrush.GetHashCode().ToString(), tbHoeheBitmap.BorderBrush.GetHashCode().ToString(), tbAnzahlKoordinaten.BorderBrush.GetHashCode().ToString()))
                {
                    MessageBox.Show("Leider beinhalten die Eingabefelder falsche Werte.\n\nVersuchen Sie es bitte erneut.", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    try
                    {
                        Vorschau.Properties.Settings.Default.BreiteBitmap = Int32.Parse(tbBreiteBitmap.Text);
                        Vorschau.Properties.Settings.Default.HoeheBitmap = Int32.Parse(tbHoeheBitmap.Text);
                        Vorschau.Properties.Settings.Default.AnzahlKoordinaten = Int32.Parse(tbAnzahlKoordinaten.Text);
                        MessageBox.Show("Einstellungen wurden erfolgreich abgespeichert.", "Speicherung erfolgreich", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                    }
                    catch (Exception error)
                    {

                        MessageBox.Show("Unglücklicherweise trat beim Speichervorgang ein Fehler auf.\n\nVersuchen Sie es bitte erneut.", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
                        Debug.WriteLine("Error - beim Speichervorgang " + error);
                    }
                }            
        }

        private void tbBreiteBitmap_LostFocus(object sender, RoutedEventArgs e)
        {
            try
            {
                if (kontrolliereObZahl(tbBreiteBitmap.Text) == false)
                {
                    tbBreiteBitmap.BorderBrush = Brushes.Red;
                }
                else
                {
                    tbBreiteBitmap.BorderBrush = Brushes.LightGray;
                }
            }
            catch (Exception error)
            {
                Debug.WriteLine("Error 'tbBreitBitMap'" + error);
            }
        }

        private void tbHoeheBitmap_LostFocus(object sender, RoutedEventArgs e)
        {
            try
            {
                if (kontrolliereObZahl(tbHoeheBitmap.Text) == false)
                {
                    tbHoeheBitmap.BorderBrush = Brushes.Red;
                }
                else
                {
                    tbHoeheBitmap.BorderBrush = Brushes.LightGray;
                }
            }
            catch (Exception error)
            {
                Debug.WriteLine("Error 'tbHoeheBitmap'" + error);
            }
        }

        private void tbAnzahlKoordinaten_LostFocus(object sender, RoutedEventArgs e)
        {
            try
            {
                if (kontrolliereObZahl(tbAnzahlKoordinaten.Text) == false)
                {
                    tbAnzahlKoordinaten.BorderBrush = Brushes.Red;
                }
                else
                {
                    tbAnzahlKoordinaten.BorderBrush = Brushes.LightGray;
                }
            }
            catch (Exception error)
            {
                Debug.WriteLine("Error 'tbAnzahlKoordinaten'" + error);
            }
        }
    }
}
<UserControl x:Class="Vorschau.UCEinstellung"
             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:local="clr-namespace:Vorschau"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid Margin="0,0,-326,-161">
        <TextBox x:Name="tbBreiteBitmap" HorizontalAlignment="Left" Height="23" Margin="145,38,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="85" LostFocus="tbBreiteBitmap_LostFocus"/>
        <TextBox x:Name="tbHoeheBitmap" HorizontalAlignment="Left" Height="23" Margin="145,83,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="85" LostFocus="tbHoeheBitmap_LostFocus"/>
        <Label x:Name="label" Content="Breite:" HorizontalAlignment="Left" Margin="10,36,0,0" VerticalAlignment="Top"/>
        <Label x:Name="label_Copy" Content="Höhe:" HorizontalAlignment="Left" Margin="10,77,0,0" VerticalAlignment="Top"/>
        <Label x:Name="label_Copy1" Content="in PX" HorizontalAlignment="Left" Margin="247,35,0,0" VerticalAlignment="Top"/>
        <Label x:Name="label_Copy2" Content="in PX" HorizontalAlignment="Left" Margin="247,77,0,0" VerticalAlignment="Top"/>
        <Label x:Name="label1" Content="einstellbare Größe des Bitmaps" HorizontalAlignment="Left" Margin="10,5,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
        <Label x:Name="label1_Copy" Content="einstellbare Zahl der geenerierten Koordinaten" HorizontalAlignment="Left" Margin="10,172,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
        <Label x:Name="label_Copy3" Content="Anzahl Koordinaten:" HorizontalAlignment="Left" Margin="10,203,0,0" VerticalAlignment="Top"/>
        <TextBox x:Name="tbAnzahlKoordinaten" HorizontalAlignment="Left" Height="23" Margin="145,203,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="85" LostFocus="tbAnzahlKoordinaten_LostFocus"/>
        <Image x:Name="image" HorizontalAlignment="Left" Height="350" Margin="289,10,0,0" VerticalAlignment="Top" Width="350" Source="img/imageedit_1_9734874017.png" RenderTransformOrigin="0.5,0.5">
            <Image.RenderTransform>
                <TransformGroup>
                    <ScaleTransform ScaleY="1"/>
                    <SkewTransform/>
                    <RotateTransform/>
                    <TranslateTransform/>
                </TransformGroup>
            </Image.RenderTransform>
        </Image>
        <Label x:Name="label1_Copy1" Content="Wertebreich des Koordinatensystems" HorizontalAlignment="Left" Margin="323,5,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
        <Canvas HorizontalAlignment="Left" Height="405" Margin="299,23,0,0" VerticalAlignment="Top" Width="3" Background="#FFB8B8B8" RenderTransformOrigin="0.5,0.5">
            <Canvas.RenderTransform>
                <TransformGroup>
                    <ScaleTransform ScaleX="-1"/>
                    <SkewTransform/>
                    <RotateTransform/>
                    <TranslateTransform/>
                </TransformGroup>
            </Canvas.RenderTransform>
        </Canvas>
        <Button x:Name="btSpeichern" Content="Speichern" HorizontalAlignment="Left" Margin="30,418,0,0" VerticalAlignment="Top" Width="75" Click="btSpeichern_Click"/>
    </Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 Vorschau
{
    /// <summary>
    /// Interaktionslogik für MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        UCEinstellung einstellung = new UCEinstellung();
        UCVorschau vorschau = new UCVorschau();

        public MainWindow()
        {
            InitializeComponent();
            MouseDown += Window_MouseDown;

            einstellung.tbBreiteBitmap.Text = Vorschau.Properties.Settings.Default.BreiteBitmap.ToString();
            einstellung.tbHoeheBitmap.Text = Vorschau.Properties.Settings.Default.HoeheBitmap.ToString();
            einstellung.tbAnzahlKoordinaten.Text = Vorschau.Properties.Settings.Default.AnzahlKoordinaten.ToString();

        }

        private void Window_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
                DragMove();
        }

        private void lbClose_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            this.Close();
        }

        private void lbMinimize_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            WindowState = WindowState.Minimized;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            lbWhereIAm.Content = "Vorschau";
            conCon.Content = vorschau;
        }

        private void btEinstellung_Click(object sender, RoutedEventArgs e)
        {
            lbWhereIAm.Content = "Einstellung";
            einstellung.tbBreiteBitmap.Text = "Test";
            conCon.Content = einstellung;
            einstellung.tbBreiteBitmap.Text = Vorschau.Properties.Settings.Default.BreiteBitmap.ToString();
            einstellung.tbHoeheBitmap.Text = Vorschau.Properties.Settings.Default.HoeheBitmap.ToString();
            einstellung.tbAnzahlKoordinaten.Text = Vorschau.Properties.Settings.Default.AnzahlKoordinaten.ToString();

        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 Vorschau
{
    /// <summary>
    /// Interaktionslogik für MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        UCEinstellung einstellung = new UCEinstellung();
        UCVorschau vorschau = new UCVorschau();

        public MainWindow()
        {
            InitializeComponent();
            MouseDown += Window_MouseDown;

            einstellung.tbBreiteBitmap.Text = Vorschau.Properties.Settings.Default.BreiteBitmap.ToString();
            einstellung.tbHoeheBitmap.Text = Vorschau.Properties.Settings.Default.HoeheBitmap.ToString();
            einstellung.tbAnzahlKoordinaten.Text = Vorschau.Properties.Settings.Default.AnzahlKoordinaten.ToString();

        }

        private void Window_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
                DragMove();
        }

        private void lbClose_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            this.Close();
        }

        private void lbMinimize_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            WindowState = WindowState.Minimized;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            lbWhereIAm.Content = "Vorschau";
            conCon.Content = vorschau;
        }

        private void btEinstellung_Click(object sender, RoutedEventArgs e)
        {
            lbWhereIAm.Content = "Einstellung";
            einstellung.tbBreiteBitmap.Text = "Test";
            conCon.Content = einstellung;
            einstellung.tbBreiteBitmap.Text = Vorschau.Properties.Settings.Default.BreiteBitmap.ToString();
            einstellung.tbHoeheBitmap.Text = Vorschau.Properties.Settings.Default.HoeheBitmap.ToString();
            einstellung.tbAnzahlKoordinaten.Text = Vorschau.Properties.Settings.Default.AnzahlKoordinaten.ToString();

        }
    }
}
<Window x:Name="windowsForm" x:Class="Vorschau.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:local="clr-namespace:Vorschau"
        mc:Ignorable="d"
        Title="Vorschaukomponente" Height="514.583" Width="805.208" FontFamily="Century Gothic" WindowStartupLocation="Manual" BorderThickness="0" ResizeMode="NoResize" WindowStyle="None" Icon="img/coordinates.ico" Background="{x:Null}" AllowsTransparency="True">
    <Window.Resources>

        <Style x:Key="border_res" TargetType="{x:Type Border}">
            <Setter Property="Background" Value="#3A3A3B" />
            <Setter Property="CornerRadius" Value="10" />
        </Style>
    </Window.Resources>

    <Border Style="{StaticResource border_res}">
        <Grid>
            <Canvas HorizontalAlignment="Left" Height="60" VerticalAlignment="Top" Width="185" Background="#FFE57E31">
                <Canvas Height="64" Canvas.Top="451" Width="185" Background="#FF2C373F">
                    <Label x:Name="lbCopyright" Content="©  Name 2017" Canvas.Left="10" Canvas.Top="29" Width="121" Foreground="#FF1B1D1F"/>
                </Canvas>
                <Canvas Height="391" Canvas.Top="60" Width="185" Background="#FF37424A">
                    <Button x:Name="btVorschau" Content="Vorschau" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="185" Height="50" Foreground="LightGray" FontSize="16"
                HorizontalContentAlignment="Left" BorderBrush="{x:Null}" Click="Button_Click">
                        <Button.Style>
                            <Style TargetType="{x:Type Button}">
                                <Setter Property="Background" Value="#FF37424A"/>
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type Button}">
                                            <Border Background="{TemplateBinding Background}">
                                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                            </Border>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                                <Style.Triggers>
                                    <Trigger Property="IsMouseOver" Value="True">
                                        <Setter Property="Background" Value="#FF303B43"/>
                                        <Setter Property="Foreground" Value="Red"/>
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </Button.Style>
                    </Button>
                    <Button x:Name="btEinstellung" Content="Einstellung" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="185" Height="50" Foreground="LightGray" FontSize="16"
                        HorizontalContentAlignment="Left" BorderBrush="{x:Null}" Canvas.Top="50" Click="btEinstellung_Click">
                        <Button.Style>
                            <Style TargetType="{x:Type Button}">
                                <Setter Property="Background" Value="#FF37424A"/>
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type Button}">
                                            <Border Background="{TemplateBinding Background}">
                                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                            </Border>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                                <Style.Triggers>
                                    <Trigger Property="IsMouseOver" Value="True">
                                        <Setter Property="Background" Value="#FF303B43"/>
                                        <Setter Property="Foreground" Value="Red"/>
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </Button.Style>
                    </Button>
                </Canvas>
                <Canvas Height="60" Canvas.Left="185" Width="618" Background="#FFEEE9ED">
                    <Label x:Name="lbClose" Content="X" Canvas.Left="578" FontSize="20" MouseDoubleClick="lbClose_MouseDoubleClick"/>
                    <Label x:Name="lbMinimize" Content="-" Canvas.Left="556" FontSize="22" Canvas.Top="-2" MouseDoubleClick="lbMinimize_MouseDoubleClick"/>
                    <Label x:Name="lbWhereIAm" Content="Label" Canvas.Left="10" Canvas.Top="15" Width="162" FontSize="20"/>
                </Canvas>
                <Canvas x:Name="canvasContent" Height="455" Canvas.Left="185" Canvas.Top="60" Width="618" Background="#FFD1CFD0"/>
                <Image x:Name="image" Height="38" Canvas.Left="10" Canvas.Top="10" Width="38" Source="img/coordinatesWhite.png"/>
                <Label x:Name="lbLogoname" Content="Vorschaukomponente" Canvas.Left="37" Canvas.Top="10" Width="143" FontWeight="Bold" Foreground="White"/>
            </Canvas>
            <ContentControl x:Name="conCon" Content="ContentControl" Canvas.Left="86" Canvas.Top="31" Margin="185,60,0,0" Foreground="#FF002EFF"/>
        </Grid>
    </Border>
</Window>
Vorschau.Properties.Settings.Default.Save();