Search code examples
c#wpfwpftoolkitmaskedtextbox

Exception from SetConnectionId when using MaskedTextBox from Xceed.Wpf.Toolkit


I'm going to used a MaskedTextbox for my wpf project so I can have a textbox that has a Mask. I'm perfectly new on how to use it. The instructions was to download the extended wpf toolkit, reference it to your project and it will work.

So when i build the project, no errors has shown. But when I tried to go to the form where there is a maskedtextbox, error 'Set connectionId threw an exception' is being found. Hope someone knows the solution. I tried rebuilding it like some of the post I saw but to no avail it still shows up. My xaml code is:

 <Page x:Class="Kiosk_Lobby_System.Transaction.Deposit.CashDeposit"
  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:wpftool="clr-namespace:Xceed.Wpf.Toolkit;assembly=Xceed.Wpf.Toolkit"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  mc:Ignorable="d" 
  d:DesignHeight="450" d:DesignWidth="790"
Title="CashDeposit" Loaded="Page_Loaded" >

<Grid>
    <Grid Margin="10,10,-10,-10">
        <Frame Name="frame1" HorizontalAlignment="Right" Width="329" Margin="0,0,0,-16">
            <Frame.Content>
                <Grid Margin="0 90 0 0" HorizontalAlignment="Right" Width="339" Height="508">
                    <WrapPanel ItemHeight="73" ItemWidth="83" Height="385" Width="255" HorizontalAlignment="Center" Name="wrapPanel1" VerticalAlignment="Center" Margin="0,9,-20,114">
                        <Button Style="{StaticResource ResourceKey=keybutton}" Content="1" FontSize="26" Height="65" Name="button_numeric_1" VerticalAlignment="Top" HorizontalAlignment="Left" Width="75" Click="button_numeric_1_Click" FontFamily="Arial" />
                        <Button Style="{StaticResource ResourceKey=keybutton}" Content="2" FontSize="26" Height="65" HorizontalAlignment="Left" Name="button_numeric_2" VerticalAlignment="Top" Width="75" Click="button_numeric_2_Click" FontFamily="Arial" />
                        <Button Style="{StaticResource ResourceKey=keybutton}" Content="3" FontSize="26" Height="65" HorizontalAlignment="Left" Name="button_numeric_3" VerticalAlignment="Top" Width="75" Click="button_numeric_3_Click" FontFamily="Arial" />
                        <Button Style="{StaticResource ResourceKey=keybutton}" Content="4" FontSize="26" Height="65" HorizontalAlignment="Left" Name="button_numeric_4" VerticalAlignment="Top" Width="75" Click="button_numeric_4_Click" FontFamily="Arial" />
                        <Button Style="{StaticResource ResourceKey=keybutton}" Content="5" FontSize="26" Height="65" HorizontalAlignment="Left" Name="button_numeric_5" VerticalAlignment="Top" Width="75" Click="button_numeric_5_Click" FontFamily="Arial" />
                        <Button Style="{StaticResource ResourceKey=keybutton}" Content="6" FontSize="26" Height="65" HorizontalAlignment="Left" Name="button_numeric_6" VerticalAlignment="Top" Width="75" Click="button_numeric_6_Click" FontFamily="Arial" />
                        <Button Style="{StaticResource ResourceKey=keybutton}" Content="7" FontSize="26" Height="65" HorizontalAlignment="Left" Name="button_numeric_7" VerticalAlignment="Top" Width="75" Click="button_numeric_7_Click" FontFamily="Arial" />
                        <Button Style="{StaticResource ResourceKey=keybutton}" Content="8" FontSize="26" Height="65" HorizontalAlignment="Left" Name="button_numeric_8" VerticalAlignment="Top" Width="75" Click="button_numeric_8_Click" FontFamily="Arial" />
                        <Button Style="{StaticResource ResourceKey=keybutton}" Content="9" FontSize="26" Height="65" HorizontalAlignment="Left" Name="button_numeric_9" VerticalAlignment="Top" Width="75" Click="button_numeric_9_Click" FontFamily="Arial" />
                        <Button Style="{StaticResource ResourceKey=keybutton}" Content="." FontSize="26" Height="65" HorizontalAlignment="Left" Name="button_numeric_dot" VerticalAlignment="Top" Width="75" OpacityMask="{x:Null}" Click="button_numeric_dot_Click" FontFamily="Arial"></Button>
                        <Button Style="{StaticResource ResourceKey=keybutton}" Content="0" FontSize="26" Height="65" HorizontalAlignment="Left" Name="button_numeric_0" VerticalAlignment="Top" Width="75" OpacityMask="{x:Null}" Foreground="Black" Click="button_numeric_0_Click" FontFamily="Arial" />
                        <Button Style="{StaticResource ResourceKey=keybutton}" Content="Del" FontSize="26" Height="65" HorizontalAlignment="Left" Name="button_numeric_delete" VerticalAlignment="Top" Width="75" Click="button_numeric_delete_Click" FontFamily="Arial" />
                    </WrapPanel>
                    <WrapPanel Height="72" Width="255" HorizontalAlignment="Center" Name="wrapPanel2" VerticalAlignment="Center" Margin="0,298,-20,138">
                        <Button Style="{StaticResource ResourceKey=keybutton}" Content="Clear All" FontSize="26" Height="65" HorizontalAlignment="Left" Name="button_numeric_clear" VerticalAlignment="Top" Width="241" OpacityMask="{x:Null}" Click="button_numeric_clear_Click" FontFamily="Arial"></Button>
                    </WrapPanel>
                </Grid>
            </Frame.Content>
        </Frame>
        <Frame HorizontalAlignment="Left" Name="frame2" Width="454" Margin="43,-28,0,12">

            <Frame.Content>
                <GroupBox Name="groupBox1" Width="416" Height="405" Margin="0 85 0 0" IsEnabled="True" HorizontalAlignment="Right">
                    <Grid Margin="0 -40 0 0" HorizontalAlignment="Center" VerticalAlignment="Center" Width="413" Height="367" >
                        <Label Style="{StaticResource label}" Content="Account Number:" 
                               FontSize="22" FontWeight="Bold"  Height="45" 
                               HorizontalAlignment="Stretch" HorizontalContentAlignment="Left"
                               Margin="56,70,6,0" Name="lblAcccountNumber" 
                               VerticalAlignment="Top" VerticalContentAlignment="Center" />
          <wpftool:MaskedTextBox FontSize="22" Height="47" HorizontalAlignment="Center"
                                    HorizontalContentAlignment="Right" IsEnabled="True" Margin="0,117,0,0"
                                    Name="txtAccountNo" PreviewTextInput="number" VerticalAlignment="Top" 
                                    VerticalContentAlignment="Center" Width="300" PreviewMouseLeftButtonDown="txtAccountNo_PreviewMouseLeftButtonDown" PreviewKeyDown="txtPreviewKeyDown" PreviewMouseLeftButtonUp="txtAccountNo_PreviewMouseLeftButtonUp"
                                    Mask="_ _ _- _ _ _ - _ _ _ _ _ - _"/>
          <!--<TextBox AcceptsReturn="True" FontSize="22" Height="47" HorizontalAlignment="Center"
                                 HorizontalContentAlignment="Right" IsEnabled="True" Margin="0,117,0,0"
                                 Name="txtAccountNo" PreviewTextInput="number" VerticalAlignment="Top" 
                                 VerticalContentAlignment="Center" Width="300" PreviewMouseLeftButtonDown="txtAccountNo_PreviewMouseLeftButtonDown" PreviewKeyDown="txtPreviewKeyDown" PreviewMouseLeftButtonUp="txtAccountNo_PreviewMouseLeftButtonUp" />-->
                        <Label Style="{StaticResource label}" Content="If PSBank prepaid, indicate the card number." 
                               FontSize="12" Height="32" 
                               HorizontalAlignment="Stretch" HorizontalContentAlignment="Left"
                               Margin="56,165,6,0" Name="lblAcccountNumberMessage" 
                               VerticalAlignment="Top" VerticalContentAlignment="Center" />

                        <Label Style="{StaticResource label}" Content="Amount:" FontSize="22" 
                               FontWeight="Bold"  Height="45" HorizontalAlignment="Stretch"
                               HorizontalContentAlignment="Left" Margin="56,200,5,0"
                               Name="lblAmount" VerticalAlignment="Top" 
                               VerticalContentAlignment="Center" />

                        <TextBox AcceptsReturn="True" FontSize="22" Height="47" HorizontalAlignment="Center"
                                 HorizontalContentAlignment="Right" IsEnabled="True" Margin="56,244,58,0"
                                 Name="txtAmount" PreviewTextInput="number" VerticalAlignment="Top" 
                                 VerticalContentAlignment="Center" Width="300" PreviewMouseLeftButtonDown="txtAmount_PreviewMouseLeftButtonDown"
                                 PreviewKeyDown="txtPreviewKeyDown" IsReadOnly="False" PreviewMouseLeftButtonUp="txtAmount_PreviewMouseLeftButtonUp" LostFocus="txtAmount_LostFocus" />

                        <Button  Content="OK" FontSize="22" Height="45" HorizontalAlignment="Right"
                                Margin="0,0,62,-20"  Name="btnCashDeposit_next" Style="{StaticResource button}"
                                 VerticalAlignment="Bottom" Width="130" Click="btnCashDeposit_next_Click" />
                        <Button Content="Back" FontSize="22" Height="45" HorizontalAlignment="Left"  Margin="58,0,0,-20"  
                                Name="btnCashDeposit_cancel" Style="{StaticResource button}" VerticalAlignment="Bottom" Width="130" Click="btnCashDeposit_cancel_Click" />
        </Grid>
                </GroupBox>
            </Frame.Content>
        </Frame>
        <Label Style="{StaticResource label2}" Content="Cash Deposit"  FontSize="32"
               FontWeight="Bold" Height="50" HorizontalAlignment="Center" 
               HorizontalContentAlignment="Center" Margin="-10,15,0,0" Name="labelTitle" 
               VerticalAlignment="Top" VerticalContentAlignment="Center" Width="800" />
    </Grid>
</Grid>
 </Page>

Solution

  • Thanks everyone for the suggestions you made! Got it working by setting up the copy local to True then adding xmlns:customName="wpftool" to the xaml! :)