How to change txtPIN.Text value in C# code behind after UserControl was initialized.
Here is XAML
<Button x:Name="btn_pin" Content="Change PIN" Click="button_Click" Foreground="White">
<Button.Template>
<ControlTemplate TargetType="Button">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<Image Source="/Assets/images/settings/lock.png" Stretch="UniformToFill" Width="16" Height="16"/>
<TextBlock x:Name="txtPin" Text="Change PIN" Foreground="White" />
</StackPanel>
</ControlTemplate>
</Button.Template>
</Button>
and C#
public MyUserControl()
{
this.InitializeComponent();
this.btn_pin.??????????
}
You're not doing it the right way, just fix your xaml (I changed the Text binding of your TextBlock):
<Button x:Name="btn_pin" Content="Change PIN" Click="button_Click" Foreground="White">
<Button.Template>
<ControlTemplate TargetType="Button">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<Image Source="/Assets/images/settings/lock.png" Stretch="UniformToFill" Width="16" Height="16"/>
<TextBlock x:Name="txtPin" Text="{TemplateBinding Content}" Foreground="White" />
</StackPanel>
</ControlTemplate>
</Button.Template>
</Button>
and every time you want to change the text, change the Content of the button like this:
public MainPage()
{
this.InitializeComponent();
btn_pin.Content = "New label";
}
Related
i've made an application in WPF with custom minimize, maximize and close buttons. In Windows 10 all works fine but when i install the application on an Windows 2012 server the Images in the button are gone. When you click on the the place where the buttons ment to be the actions work fine only no Images.
When i resize the app the images appear to be stuk in the middel of the application. when i resize smaller the image stay in the button when i go bigger the images leave the buttons.
What is going on. Is there anyone who had the same issue?
<Button x:Name="MinimizeButton" Padding="3" Width="25" BorderThickness="1" BorderBrush="White" Height="25" VerticalAlignment="Top" Margin="0,0,55,0" Click="MinimizeButton_Click" HorizontalAlignment="Right" Grid.Column="1">
<Button.Template>
<ControlTemplate>
<Grid>
<Image Source="Images/minimizeIconRed.png" Height="23" Width="23"/>
<ContentPresenter/>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
<Button x:Name="MaximizeButton" Padding="4" Width="25" BorderThickness="1" BorderBrush="White" Height="25" VerticalAlignment="Top" Margin="0,0,30,0" Click="MaximizeButton_Click" HorizontalAlignment="Right" Grid.Column="1">
<Button.Template>
<ControlTemplate>
<Grid>
<Image Source="Images/maximizeIconRed.png" Height="23" Width="23"/>
<ContentPresenter/>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
<Button Width="25" Padding="4" BorderThickness="1" BorderBrush="White" Height="25" VerticalAlignment="Top" Margin="0,0,5,0" HorizontalAlignment="Right" Click="Button_Click_1" Grid.Column="1" Background="{x:Null}">
<Button.Template>
<ControlTemplate>
<Grid>
<Image Source="Images/closeIconRed.png" Height="23" Width="23"/>
<ContentPresenter/>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
The problem is with the default LowQuality BitmapScalingMode (default changed in 4.0)
Changing to RenderOptions.BitmapScaling="HighQuality" seemed to fix the issue for me.
<Button x:Name="MinimizeButton" Padding="3" Width="25" BorderThickness="1" BorderBrush="White" Height="25" VerticalAlignment="Top" Margin="0,0,55,0" Click="MinimizeButton_Click" HorizontalAlignment="Right" Grid.Column="1">
<Button.Template>
<ControlTemplate>
<Grid>
<Image Source="Images/minimizeIconRed.png" Height="23" Width="23" RenderOptions.BitmapScalingMode="HighQuality"/>
<ContentPresenter/>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
<Button x:Name="MaximizeButton" Padding="4" Width="25" BorderThickness="1" BorderBrush="White" Height="25" VerticalAlignment="Top" Margin="0,0,30,0" Click="MaximizeButton_Click" HorizontalAlignment="Right" Grid.Column="1">
<Button.Template>
<ControlTemplate>
<Grid>
<Image Source="Images/maximizeIconRed.png" Height="23" Width="23" RenderOptions.BitmapScalingMode="HighQuality"/>
<ContentPresenter/>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
<Button Width="25" Padding="4" BorderThickness="1" BorderBrush="White" Height="25" VerticalAlignment="Top" Margin="0,0,5,0" HorizontalAlignment="Right" Click="Button_Click_1" Grid.Column="1" Background="{x:Null}">
<Button.Template>
<ControlTemplate>
<Grid>
<Image Source="Images/closeIconRed.png" Height="23" Width="23" RenderOptions.BitmapScalingMode="HighQuality"/>
<ContentPresenter/>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
I have a button on top of which I have put an image. How can I set the size of the button to be same as the size of the image? Please note I cannot use "Height" and "Width" property because my form is suppose to resize
<Button Grid.Column="1" Grid.Row="1" Click="Button_Click" >
<Button.Template>
<ControlTemplate>
<Border HorizontalAlignment="Center" VerticalAlignment="Center" >
<Image Source="pack://application:,,,/WpfApplication5;component/myimage.png" Stretch="Uniform" VerticalAlignment="Top" HorizontalAlignment="Center"/>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
Try this:
<Button Grid.Column="1" Grid.Row="1" Click="Button_Click" Width="{Binding ElementName=img,Path=Width}" Height="{Binding ElementName=img,Path=Height}">
<Button.Template>
<ControlTemplate>
<Border HorizontalAlignment="Center" VerticalAlignment="Center" >
<Image x:Name="img" Source="pack://application:,,,/WpfApplication5;component/myimage.png" Stretch="Uniform" VerticalAlignment="Top" HorizontalAlignment="Center"/>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
But, one suggestion: the button automatically resize with his content.
I have listbox control with custom data template. I get the collection from webservice and bind that collection to listbox. When i scroll the list box top to bottom my listbox rows are changed and text are concatenate.
Please see the below images
This is my first screen
when scroll top to bottom once again
please compare two images my rows are changed
<Grid Margin="30,20,0,20" x:Name="MeGrid" Loaded="MeGrid_Loaded" Visibility="{Binding Path=_isMyMessage, Converter={StaticResource BoolToVisibilityConverter}}">
<StackPanel >
<TextBlock HorizontalAlignment="Right" Foreground="#00c0d4" Margin="0,0,100,0" Text="{Binding Path=CreatedDate, Converter={StaticResource TimeSinceConverter}}" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Grid Background="#ffffff" Height="auto" Width="auto" MaxWidth="300" MinWidth="50">
<StackPanel Background="White">
<RichTextBox Name="MeRich" Background="White" MaxHeight="600" Foreground="Red"
FontFamily="Segoe UI" Margin="10,0,10,0" VerticalAlignment="Center"
TextWrapping="Wrap" Height="auto"
Width="auto" MinWidth="50"
MaxWidth="300"
local:Properties.Html="{Binding Path=MessageText}">
</RichTextBox>
<readMore:Readmore Source="{Binding Path=MessageText}" Visibility="{Binding ActualHeight,
ElementName=MeRich, Converter={StaticResource ReadMoreVisibilityConverter}}" ></readMore:Readmore>
<!--<TextBlock Margin="10,0,10,0" VerticalAlignment="Center" Foreground="Black" TextWrapping="Wrap" Height="auto" Width="auto" MinWidth="50" MaxWidth="300" Text="{Binding Path=MessageText}"
/>-->
<ListBox ScrollViewer.VerticalScrollBarVisibility="Disabled" ItemsSource="{Binding Path=AttachmentList}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Margin="0,5,0,5">
<Button Click="Image_Download" Loaded="Button_Loaded" Tag="{Binding .}" Width="80" Height="80" >
<Button.Template>
<ControlTemplate TargetType="Button">
<Border HorizontalAlignment="Center" VerticalAlignment="Center" >
<ContentControl Content="{TemplateBinding Content}"/>
</Border>
</ControlTemplate>
</Button.Template>
<Image Source="/Resources/Drawable/c_image.png" Tag="{Binding .}" />
</Button>
<ProgressBar VerticalAlignment="Bottom" IsIndeterminate="true" Visibility="Collapsed" Style="{StaticResource CustomIndeterminateProgressBar}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</Grid>
<Rectangle Margin="20,0,0,0" VerticalAlignment="Top" RadiusX="50" RadiusY="50" Width="80" Height="80">
<Rectangle.Fill>
<ImageBrush ImageSource="{Binding Path=UserPictureURL}"/>
</Rectangle.Fill>
</Rectangle>
</StackPanel>
</StackPanel>
</Grid>
I am doing validation of all text boxes using IDataErrorInfo on my WPF form like this:
<TextBox Name="txtAddress"
Validation.Error="Validation_Error"
Text="{Binding Path=Address, UpdateSourceTrigger=LostFocus,
ValidatesOnDataErrors=True, NotifyOnValidationError=True}">
// If I have many TextBoxes to validate, I have to copy this and paste
// for each TextBox in XAML. This obviously violates DRY. How do I define
// this at one place and use it for all TextBoxes on my form?
<Validation.ErrorTemplate>
<ControlTemplate>
<DockPanel LastChildFill="true">
<Border Background="Red" DockPanel.Dock="right" Margin="5,0,0,0" Width="16" Height="16" CornerRadius="10"
ToolTip="{Binding ElementName=customAdorner, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}">
<TextBlock Text="!"
VerticalAlignment="center" HorizontalAlignment="center"
FontWeight="Bold" Foreground="white"/>
</Border>
<AdornedElementPlaceholder Name="customAdorner" VerticalAlignment="Center" >
<Border BorderBrush="red" BorderThickness="1" />
</AdornedElementPlaceholder>
</DockPanel>
</ControlTemplate>
</Validation.ErrorTemplate>
</TextBox>
This is my Validation_Error method used above:
private void Validation_Error(object sender, ValidationErrorEventArgs e)
{
if (e.Action == ValidationErrorEventAction.Added)
{
mNumErrors++;
}
else
{
mNumErrors--;
}
}
If I have many Textboxes on my form, I have to copy the section above into each TextBox definition in XAML. How do I define it on one place and use it for all TextBoxes?
Thanks,
1 Way. You can move ControlTemplate to the Resources of application or window. And add into textBoxes StaticResource like this.
ControlTemplate in Resources with x:Key property.
<ControlTemplate x:Key="MyErrorTemplate">
<DockPanel LastChildFill="true">
<Border Background="Red" DockPanel.Dock="right" Margin="5,0,0,0" Width="16" Height="16" CornerRadius="10"
ToolTip="{Binding ElementName=customAdorner, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}">
<TextBlock Text="!" VerticalAlignment="center" HorizontalAlignment="center"
FontWeight="Bold" Foreground="white"/>
</Border>
<AdornedElementPlaceholder Name="customAdorner" VerticalAlignment="Center" >
<Border BorderBrush="red" BorderThickness="5" />
</AdornedElementPlaceholder>
</DockPanel>
</ControlTemplate>
TextBox with assigned ErrorTemplate.
<TextBox Validation.ErrorTemplate="{StaticResource MyErrorTemplate}" />
2 Way. If all TextBoxes should contain this ErrorTemplate you can define TextBox Style in the resources and add ErrorTemplate into it. The Style will be applied to all TextBoxes.
<Style TargetType="TextBox">
<Setter Property="Validation.ErrorTemplate">
<Setter.Value>
<ControlTemplate>
...
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
They say, A Picture is Worth a Thousand Words.
I have a custom control called RichTextBoxEditor:
Here is the XAML:
<UserControl x:Class="WpfRichText.Ex.Controls.RichTextEditor" x:Name="uxRichTextEditor"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:asis="clr-namespace:WpfRichText.Ex.AttachedProperties">
<Grid >
<!-- Set the styles for the tool bar. -->
<Grid.Resources>
<Style TargetType="{x:Type Button}" x:Key="formatTextStyle">
<Setter Property="FontFamily" Value="Palatino Linotype"></Setter>
<Setter Property="Width" Value="30"></Setter>
<Setter Property="FontSize" Value ="14"></Setter>
<Setter Property="CommandTarget" Value="{Binding ElementName=mainRTB}"></Setter>
</Style>
<Style TargetType="{x:Type ToggleButton}" x:Key="formatTextStyle2">
<Setter Property="FontFamily" Value="Palatino Linotype"></Setter>
<Setter Property="Width" Value="30"></Setter>
<Setter Property="FontSize" Value ="14"></Setter>
<!--<Setter Property="CommandTarget" Value="{Binding ElementName=mainRTB}"></Setter>-->
</Style>
<Style TargetType="{x:Type Button}" x:Key="formatImageStyle">
<Setter Property="Width" Value="30"></Setter>
<!--<Setter Property="CommandTarget" Value="{Binding ElementName=mainRTB}"></Setter>-->
</Style>
</Grid.Resources>
<DockPanel Name="mainPanel">
<!-- This tool bar contains all the editing buttons. -->
<ToolBar Height="30" DockPanel.Dock="Top" ToolBarTray.IsLocked="True">
<Button Style="{StaticResource formatTextStyle}" Command="EditingCommands.ToggleBold" ToolTip="Bold">
<TextBlock FontWeight="Bold">B</TextBlock>
</Button>
<Button Style="{StaticResource formatTextStyle}" Command="EditingCommands.ToggleItalic" ToolTip="Italic">
<TextBlock FontStyle="Italic" FontWeight="Bold">I</TextBlock>
</Button>
<ToggleButton Style="{StaticResource formatTextStyle2}" x:Name="ToolStripButtonStrikeout" ToolTip="Strikethrough" Click="ToolStripButtonStrikeout_Click" Foreground="Black" Width="19" Height="19">
<ToggleButton.Background>
<ImageBrush ImageSource="pack://siteoforigin:,,,/Resources/Strikeout.png"/>
</ToggleButton.Background>
</ToggleButton>
<Button x:Name="Tool_Link" Style="{StaticResource formatImageStyle}" ToolTip="Link" Click="Tool_Link_Click" Width="30" Height="19">
<Button.Background>
<ImageBrush Stretch="Uniform" ImageSource="pack://siteoforigin:,,,/Resources/Link.png"/>
</Button.Background>
</Button>
<Button x:Name="Tool_Spoiler" Style="{StaticResource formatImageStyle}" ToolTip="Spoiler" Width="30" Height="19">
<Button.Background>
<ImageBrush Stretch="Uniform" ImageSource="pack://siteoforigin:,,,/Resources/Spoiler.png"/>
</Button.Background>
</Button>
<Button x:Name="Tool_Image" Style="{StaticResource formatImageStyle}" ToolTip="Image" Height="19">
<Button.Background>
<ImageBrush ImageSource="pack://siteoforigin:,,,/Resources/Images.png" Stretch="Uniform"/>
</Button.Background>
</Button>
<Button x:Name="Tool_Video" Style="{StaticResource formatImageStyle}" ToolTip="Youtube video" Margin="0,1,0,-1" Height="19">
<Button.Background>
<ImageBrush ImageSource="pack://siteoforigin:,,,/Resources/Video.png" Stretch="Uniform"/>
</Button.Background>
</Button>
<Button x:Name="Tool_ALeft" Style="{StaticResource formatImageStyle}" ToolTip="Align Left" Height="19" Width="30">
<Button.Background>
<ImageBrush ImageSource="pack://siteoforigin:,,,/Resources/paragraphleftjustify.png" Stretch="Uniform"/>
</Button.Background>
</Button>
<Button x:Name="Tool_ACenter" Style="{StaticResource formatImageStyle}" ToolTip="Align Center" Height="19">
<Button.Background>
<ImageBrush Stretch="Uniform" ImageSource="pack://siteoforigin:,,,/Resources/paragraphcenterjustify.png"/>
</Button.Background>
</Button>
<Button x:Name="Tool_Header" Style="{StaticResource formatImageStyle}" ToolTip="Header" Height="19">
<Button.Background>
<ImageBrush Stretch="Uniform" ImageSource="pack://siteoforigin:,,,/Resources/charactergrowfont.png"/>
</Button.Background>
</Button>
<Button x:Name="Tool_Quote" Style="{StaticResource formatImageStyle}" ToolTip="Quote" Height="19">
<Button.Background>
<ImageBrush Stretch="Uniform" ImageSource="pack://siteoforigin:,,,/Resources/quote.png"/>
</Button.Background>
</Button>
<Button x:Name="Tool_Code" Style="{StaticResource formatImageStyle}" ToolTip="Decrease Indent" Height="19">
<Button.Background>
<ImageBrush Stretch="Uniform" ImageSource="pack://siteoforigin:,,,/Resources/code.png"/>
</Button.Background>
</Button>
</ToolBar>
<StackPanel >
<RichTextBox Name="mainRTB" AcceptsTab="True" Height="160"
asis:RichTextboxAssistant.BoundDocument="{Binding Path=Text, ElementName=uxRichTextEditor}"
VerticalScrollBarVisibility="Visible" Width="365" />
<!--<TextBox Text="{Binding Path=Text, ElementName=uxRichTextEditor}" Height="25" />-->
</StackPanel>
</DockPanel>
</Grid>
This control originally was taken from the net, which i forgot where it is. But then i modified some component of it. It was fine while in Designer, but when i put it on the main window, it will look like this:
Here is some information that may useful:
Thanks in Advance :)
EDIT:
Here is the original XAML:
<UserControl
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:RTFEditor="clr-namespace:RTFEditor"
mc:Ignorable="d"
x:Class="RTFEditor.RTFBox"
x:Name="RTFEditor"
d:DesignWidth="600" d:DesignHeight="600" Loaded="RTFEditor_Loaded">
<UserControl.Resources>
<ObjectDataProvider x:Key="FontListKlasse" d:IsDataSource="True" ObjectType="{x:Type RTFEditor:FontList}"/>
<ObjectDataProvider x:Key="FontHeightKlasse" d:IsDataSource="True" ObjectType="{x:Type RTFEditor:FontHeight}"/>
</UserControl.Resources>
<DockPanel>
<ToolBar x:Name="ToolBarOben" DockPanel.Dock="Top">
<Button x:Name="ToolStripButtonOpen" Click="ToolStripButtonOpen_Click">
<Image Source="Images\Open.png" Stretch="None"/>
</Button>
<Button x:Name="ToolStripButtonPrint" Click="ToolStripButtonPrint_Click">
<Image Source="Images\Print.png" Stretch="None"/>
</Button>
<Separator/>
<Button x:Name="ToolStripButtonCut" Command="ApplicationCommands.Cut" ToolTip="Cut">
<Image Source="Images\Cut.png" Stretch="None"/>
</Button>
<Button x:Name="ToolStripButtonCopy" Command="ApplicationCommands.Copy" ToolTip="Copy">
<Image Source="Images\Copy.png" Stretch="None"/>
</Button>
<Button x:Name="ToolStripButtonPaste" Command="ApplicationCommands.Paste" ToolTip="Paste">
<Image Source="Images\Paste.png" Stretch="None"/>
</Button>
<Button x:Name="ToolStripButtonUndo" Command="ApplicationCommands.Undo" ToolTip="Undo">
<Image Source="Images\Undo.png" Stretch="None"/>
</Button>
<Button x:Name="ToolStripButtonRedo" Command="ApplicationCommands.Redo" ToolTip="Redo">
<Image Source="Images\Redo.png" Stretch="None"/>
</Button>
<Separator/>
<ComboBox x:Name="Fonttype" ItemsSource="{Binding Mode=OneWay, Source={StaticResource FontListKlasse}}" DropDownClosed="Fonttype_DropDownClosed" />
<ComboBox x:Name="Fontheight" ItemsSource="{Binding Mode=OneWay, Source={StaticResource FontHeightKlasse}}" DropDownClosed="Fontheight_DropDownClosed" />
</ToolBar>
<ToolBar x:Name="ToolBarUnten" DockPanel.Dock="Top">
<ToggleButton x:Name="ToolStripButtonBold" Command="EditingCommands.ToggleBold" ToolTip="Bold">
<Image Source="Images\Bold.png" Stretch="None"/>
</ToggleButton>
<ToggleButton x:Name="ToolStripButtonItalic" Command="EditingCommands.ToggleItalic" ToolTip="Italic">
<Image Source="Images\Italic.png" Stretch="None"/>
</ToggleButton>
<ToggleButton x:Name="ToolStripButtonUnderline" Command="EditingCommands.ToggleUnderline" ToolTip="Underline">
<Image Source="Images\Underline.png" Stretch="None"/>
</ToggleButton>
<ToggleButton x:Name="ToolStripButtonStrikeout" ToolTip="Strikeout" Click="ToolStripButtonStrikeout_Click">
<Image Source="Images\Strikeout.png" Stretch="None"/>
</ToggleButton>
<Separator/>
<Button x:Name="ToolStripButtonTextcolor" Click="ToolStripButtonTextcolor_Click">
<Image Source="Images\Textcolor.png" Stretch="None"/>
</Button>
<Button x:Name="ToolStripButtonBackcolor" Click="ToolStripButtonBackcolor_Click">
<Image Source="Images\Backcolor.png" Stretch="None"/>
</Button>
<Separator/>
<ToggleButton x:Name="ToolStripButtonAlignLeft" Command="EditingCommands.AlignLeft" ToolTip="Align Left" Click="ToolStripButtonAlignLeft_Click">
<Image Source="Images\AlignLeft.png" Stretch="None"/>
</ToggleButton>
<ToggleButton x:Name="ToolStripButtonAlignCenter" Command="EditingCommands.AlignCenter" ToolTip="Align Center" Click="ToolStripButtonAlignCenter_Click">
<Image Source="Images\AlignCenter.png" Stretch="None"/>
</ToggleButton>
<ToggleButton x:Name="ToolStripButtonAlignRight" Command="EditingCommands.AlignRight" ToolTip="Align Right" Click="ToolStripButtonAlignRight_Click">
<Image Source="Images\AlignRight.png" Stretch="None"/>
</ToggleButton>
<Separator/>
<Button x:Name="ToolStripButtonBulletList" Command="EditingCommands.ToggleBullets" ToolTip="Bullets">
<Image Source="Images\BulletList.png" Stretch="None"/>
</Button>
<Button x:Name="ToolStripButtonNumbersList" Command="EditingCommands.ToggleNumbering" ToolTip="Numbers">
<Image Source="Images\NumbersList.png" Stretch="None"/>
</Button>
<Separator/>
<Button x:Name="ToolStripButtonIndent" Command="EditingCommands.IncreaseIndentation" ToolTip="Increase Indent">
<Image Source="Images\Indent.png" Stretch="None"/>
</Button>
<Button x:Name="ToolStripButtonIndentDelete" Command="EditingCommands.DecreaseIndentation" ToolTip="Decrease Indent">
<Image Source="Images\IndentRemove.png" Stretch="None"/>
</Button>
<Separator/>
<ToggleButton x:Name="ToolStripButtonSubscript" ToolTip="Subscript" Click="ToolStripButtonSubscript_Click">
<Image Source="Images\Subscript.png" Stretch="None"/>
</ToggleButton>
<ToggleButton x:Name="ToolStripButtonSuperscript" ToolTip="Superscript" Click="ToolStripButtonSuperscript_Click">
<Image Source="Images\Superscript.png" Stretch="None"/>
</ToggleButton>
</ToolBar>
<StatusBar x:Name="StatusBar" DockPanel.Dock="Bottom">
<StatusBarItem>
<Label x:Name="LabelZeileNr" Content="ZeileNr" BorderThickness="1" BorderBrush="DarkGray" />
</StatusBarItem>
<StatusBarItem >
<Label x:Name="LabelSpalteNr" Content="SpalteNr" BorderThickness="1" BorderBrush="DarkGray"/>
</StatusBarItem>
<StatusBarItem>
<Label x:Name="LabelEinfg" Content="Einfg" BorderThickness="1" BorderBrush="DarkGray" />
</StatusBarItem>
<StatusBarItem DockPanel.Dock="Right" Width="100">
<Slider x:Name="SliderZoom" Grid.Column="1" Width="100" Ticks="1, 2, 3, 4, 5, 6, 7, 8, 9, 10" Value="1" Delay="100" Interval="5" TickPlacement="BottomRight" Minimum="1" Maximum="10" ValueChanged="SliderZoom_ValueChanged" HorizontalContentAlignment="Left" />
</StatusBarItem>
</StatusBar>
<RichTextBox x:Name="RichTextControl" SpellCheck.IsEnabled="True" VerticalScrollBarVisibility="Auto" AcceptsReturn="True" AcceptsTab="True" SelectionChanged="RichTextControl_SelectionChanged" TextChanged="RichTextControl_TextChanged" KeyDown="RichTextControl_KeyDown" KeyUp="RichTextControl_KeyUp" />
</DockPanel>
EDIT 2nd:
If im not mistaken here is what i have done:
Added my custom images to the project resource (Linked at compile; Resource)
Changed the source of the image of each button (Except Bold & Italic)
I will update this section if i remember anything else!
More Info:
I tried to copy-paste the original XAML without modifying it. When i use it in the main window, it works! But, all images of the buttons are not showing (except Bold and Italic since they dont use any image).
RichTextEditor.xaml.cs :
namespace WpfRichText.Ex.Controls
{
/// <summary>
/// Interaction logic for BindableRichTextbox.xaml
/// </summary>
public partial class RichTextEditor : UserControl
{
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(string), typeof(RichTextEditor),
new PropertyMetadata(string.Empty));
public RichTextEditor()
{
InitializeComponent();
}
public string Text
{
get { return GetValue(TextProperty) as string; }
set {
SetValue(TextProperty, value);
}
}
private void ToolStripButtonStrikeout_Click(object sender, RoutedEventArgs e)
{
TextRange range = new TextRange(mainRTB.Selection.Start, mainRTB.Selection.End);
TextDecorationCollection tdc = (TextDecorationCollection)mainRTB.Selection.GetPropertyValue(Inline.TextDecorationsProperty);
if (tdc == null || !tdc.Equals(TextDecorations.Strikethrough))
{
tdc = TextDecorations.Strikethrough;
}
else
{
tdc = new TextDecorationCollection();
}
range.ApplyPropertyValue(Inline.TextDecorationsProperty, tdc);
}
private void Tool_Link_Click(object sender, RoutedEventArgs e)
{
}
}
}